Repository navigation
Review UI: find bar, more context, cursor line, and fixes - #9
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Review UI improvements for the diff, the guide, and the file list. Each commit is one change and has its own test.
Changes
znow also takes the focus off a hidden list, soj/kno longer move through files that do not show.tabon a hidden list shows it.+/-show ten more or fewer unchanged lines around each change. A click on a↕ N unchanged linesheader does the same as+.cursor_line = falseturns it off./(andctrl+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 forn/N; esc goes back to where it started. The search of all files and code moves from/toctrl+p.Find performance
Testing
go test ./...andgolangci-lint runpass. I have not checked the changes in a real terminal yet.