Skip to content

Review UI: find bar, more context, cursor line, and fixes - #9

Merged
frinfo702 merged 11 commits into
mainfrom
review-ui-improvements
Nov 8, 2026
Merged

frinfo702 merged 11 commits into
mainfrom
review-ui-improvements

Conversation

@frinfo702

Copy link
Copy Markdown
Owner

Review UI improvements for the diff, the guide, and the file list. Each commit is one change and has its own test.

Changes

  • Hide the file list: z now also takes the focus off a hidden list, so j/k no longer move through files that do not show. tab on a hidden list shows it.
  • Split or unified by width: the diff shows side by side only when the main pane is 80 columns or wider. The old rule (60% of the screen) passed at every width, because the list and the guide column never take more than a third. The Guide tab now switches too.
  • More context: + / - show ten more or fewer unchanged lines around each change. A click on a ↕ N unchanged lines header does the same as +.
  • Cursor line: the line at the cursor gets a faint tint. On added and deleted lines, the green or red is shaded, so the line keeps its colour. cursor_line = false turns it off.
  • Find without hiding the view: / (and ctrl+f) opens a find bar in the footer. The cursor moves to the first match as you type, and matches are painted. When the file list has the focus, it finds by file name and selects the match; files that do not match stay in the list. If the match is in a part of the path that the row cuts off, the row's … is painted. Enter keeps the find for n/N; esc goes back to where it started. The search of all files and code moves from / to ctrl+p.
  • Double click: selects and copies the word under the pointer.

Find performance

  • The find looks at the source lines of the diff, not the rendered lines: about 60 ms → 2 ms per key on 20,000 lines. It also finds text that the screen cuts off.
  • A query that adds to the last one only checks the last hits.
  • Matches are painted in one pass of the line. A one-letter query on lines with many matches took 6.8 s to draw a screen; it now takes about 3 ms.

Testing

go test ./... and golangci-lint run pass. I have not checked the changes in a real terminal yet.

z kept the focus on a hidden list, so j and k moved through files that
did not show. Hiding now gives the keys back to the code, and tab on a
hidden list shows it again.
The split layout needed the main pane to take 60% of the screen. The file
list and the guide column never take more than a third, so every width
passed and a narrow pane cut both sides. The main pane now needs 80
columns, in the Diff and in the Guide tab.
+ shows ten more lines of context around each change of the file, and -
ten fewer. A click on a "↕ N unchanged lines" header does the same as +.
The context goes back to three lines on the next file.
The line at the cursor gets a faint tint of the terminal background, to
the width of the code. Cells with a background of their own, such as an
added line or a text selection, keep it. The setting cursor_line = false
turns the tint off.
/ opens a find bar in the footer in place of the search overlay. As the
user types, the cursor moves to the first match and the matches are
painted, so the diff stays in view. When the file list has the focus,
the find looks at the names of the files and selects the first match,
and the files that do not match stay in the list. Enter keeps the find
for n and N; esc goes back to where it started. The search of all files
and code moves to ctrl+p.
A second click on the same cell of the code within 400 ms selects the
word under the pointer, its letters, digits, and underscores, and copies
it, as a release after a drag does.
The tint of the cursor line skipped the cells with a background of their
own, so an added or a deleted line at the cursor showed no tint. Those
cells now get their own background shaded, so the line keeps its green
or red and still shows the cursor.
The find stripped the escape sequences of each rendered line and blanked
its line numbers at each key, which took about 60 ms on 20,000 lines. It
now looks at the source lines that the rows number, in lower case once
per render, and takes about 2 ms. It also sees the part of a line that
the screen cuts off. Rendered markdown and the PR still match by their
text.
A query that adds to the last one matches only where the last one did,
so the find looks only at those hits. A shorter query, a new render of
the pane, or a change of the list looks at all the lines again.
paintMatches cut the whole line three times for each match, and measured
the text before each match from its start. A one-letter query on lines
with twenty matches took 6.8 s to draw a screen. paintSpans now paints
all the matches, or a text selection, in one walk of the line, and the
screen takes 3 ms. After a span, the line goes on in its own style, where
it lost its colours until its next escape sequence before.
A find in the file list matches the whole path, but a row cuts a long
directory to "…/". A file that matched only in its directory then showed
no paint, and n seemed to stop on files that did not match. The "…" of
such a row is now painted, to show that the match is in the part that is
cut off.
@frinfo702
frinfo702 merged commit ea0f69c into main Nov 8, 2026
7 of 8 checks passed
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