Skip to content

Add expand controls before first and after last diff hunk #335

@tomasz-tomczyk

Description

@tomasz-tomczyk

There are no expand controls before the first hunk or after the last hunk. GitHub and GitLab both allow expanding context in these regions, which is useful for seeing surrounding code.

Desired behavior: Show an expand-down control before the first hunk (to reveal lines 1 through hunk start) and an expand-up control after the last hunk (to reveal lines from hunk end through EOF). Expand in 20-line increments, consistent with #334.

Implementation notes:

  • Both renderDiffUnified and renderDiffSplit only render spacers when hi > 0 — need to add leading/trailing spacer calls outside the loop
  • renderDiffSpacer assumes a real prevHunk exists (click handler does hunks[prevIdx].Lines.concat()), so the leading spacer needs a special code path that prepends to hunk 0 rather than merging two hunks
  • file.content is available after load, so total line count for the trailing spacer is accessible via file.content.split('\n').length
  • Purely frontend — no backend changes needed

Refs #320

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions