Skip to content

Fold long runs of unchanged lines, and show them on → or a click - #7

Merged
rednafi merged 1 commit into
diff-barsfrom
diff-folds
Oct 26, 2026
Merged

rednafi merged 1 commit into
diff-barsfrom
diff-folds

Conversation

@rednafi

@rednafi rednafi commented Oct 25, 2026

Copy link
Copy Markdown
Owner

Fixes #2. Stacked on #6.

Change

  • The diff has the whole file. A long run of unchanged lines folds into one row: ⋯ 13 unmodified lines @@ -27,7 +27,7 @@. Three lines show beside each change, as before. A run of one line shows, because its fold saves no row. The fold at the end of a file has no @@.
  • → on a fold, or a click on it, shows its lines. The cursor goes to the first of them. On a line of code, → still scrolls sideways. The footer shows → show the lines on a fold.
  • A fold with a comment on one of its lines always shows, so a comment never hides.
  • : with a line in a fold shows the fold and goes to the line.
  • A new scope folds the lines again.
  • In the split layout, the header goes on across the right side, so the text is not cut.
  • The review text for the agent does not change: it skips header rows.
▶   …   …   ⋯ 6 unmodified lines  @@ -7,7 +7,7 @@
    7   7   line 7
   ...
    …   …   ⋯ 13 unmodified lines  @@ -27,7 +27,7 @@
   27  27   line 27
   ...
    …   …   ⋯ 7 unmodified lines

Tests

  • diff.TestFolds: the exact rows (line numbers and folds) when no fold, the middle fold, the top and the tail fold, and every fold shows; the header text in both layouts; no line is wider than the screen.
  • diff.TestFoldEdges: one line between two margins shows; an insert gives a fold different old and new numbers; a new file has no fold; the split layout has the same folds.
  • tui.TestExpandFold: → on a fold shows its 13 lines and moves the cursor to line 14; the footer hint shows only on a fold; → on code scrolls.
  • tui.TestClickFold: a click shows the tail fold in the unified layout, the split layout, and with wrap.
  • tui.TestFoldKeepsComment: a comment on a line of an expanded fold keeps the fold open after a new scope.
  • tui.TestGotoLineInFold: :20 shows the fold of line 20.
  • I checked that the tests fail when the fix of each case is removed.
  • Checked in Rex with the built binary: →, a click, :20, and the split layout.

Cost

A 20,000-line file with two changes renders in 3.3 ms, up from 3.0 ms.

The diff showed only three lines around each change, and the rest of
the file was not there. Now the diff has the whole file, and a long run
of unchanged lines folds into one row, "⋯ 13 unmodified lines", as in
herdr-reviewr. → or a click on the row shows the lines. On a line of
code, → still scrolls sideways. A fold with a comment on one of its
lines always shows, and ":" with a line in a fold shows the fold. A new
scope folds the lines again.

Fixes #2
@rednafi
rednafi merged commit 3c0dd1f into diff-bars Oct 26, 2026
3 checks passed
@rednafi
rednafi deleted the diff-folds branch October 26, 2026 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant