Repository navigation
feat(review): a file list that fits its names, with filters by name, kind and viewed - #189
Merged
Merged
Conversation
…kind and viewed The code review drew the viewer's own file list: 32 columns wide, a 2-column gutter, two columns of indent a level, a 16-column summary and a badge column, so a name got 10 to 18 columns and lost its end. Below 97 columns of diff there was no list at all. The review now draws its own list and hides the viewer's: - folder chains with one folder each are one row, folders first, sorted as the browser sorts them; the diff shows the files in the same order - the list is as wide as its rows need, up to two fifths of the room, and never takes the diff below 48 columns; `<`/`>` narrow or widen it - a long name is cut in the middle so its end and extension stay; counts, then the status letter, give way first; folders keep their last folders - without room it hides and the footer says `f` shows it; `f` makes the notes rail give way Filters, which the diff, n/N, ]/[ and ctrl+n follow: - `/` by name (every word in the path, else characters in order), live in the list, applied to the diff on enter, cleared with esc - `t` by kind: code, tests, docs, config, generated, other, with counts; tests and generated follow Plannotator's packages/core/file-kind.ts - `H` hides viewed files Notes are never filtered: the list counts unsent notes in hidden files and Send sends every note.
- n/N, the list highlight and the footer start from the file the viewer's cursor is in, whatever moved it (rail, d, ctrl+o, mouse); a heading or a binary file's note is placed by counting rows to the nearest lines, so j at a lineless last file no longer bounces back - a file replaced by a symlink is one row (T) and the diff shows both sections; a section the parser cannot name is shown again - cancelling a filter that changed nothing moves nothing and returns the focus; ctrl+c quits and paste works while typing it - go to definition or ctrl+o into a file the filter hides opens it in the whole-file view and adds no history when nothing moved - notes count as hidden only when a filter hides their file - the list keys work over the whole-file view - a screen too narrow for the list says so and shows the filter typed - narrow-files/widen-files are their own actions, so an older config that gave < or > to a code review key keeps the reading column's - data and config extensions win over documentation names; dist under src is source - columns line up; footer hints drop to fit one or two rows - .gitattributes linguist-generated is read off the event loop - rows, kinds and widths are cached for large changes
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.
Why
In code review the file list cut most names short and left a lot of empty space on the left. It was the diff viewer's built-in list (diffs-rs
src/app/sidebar.rs): a fixed 32 columns, a 2-column gutter, 2 columns of indent a level, a summary of up to 16 columns and a badge column. That left 10 to 18 columns for a name, and names were cut at the end, so the extension went first. The list needed 97 columns, so at 100 columns beside the notes there was no list.What
The review draws its own list and hides the viewer's (
SidebarPreference::Hide). The code is incrates/plannotator-tui/src/review/files/.plannotator-tui/src/). Folders come before files and sort without regard to case, as in Plannotator'sdiffFileTree.ts. The diff shows the files in the same order, so the list andn/Nagree.</>(narrow-files/widen-files) change the width by 4 columns. When there is no room (80 columns with notes) the list hides and the footer saysfshows it;fthen makes the notes rail give way.ReviewAge…lPanel.tsx). The columns are chosen once for all rows so they line up: the list widens first, then every row drops its counts, then its status letter. Folder rows keep their last folders (…/review-editor/components/). The diff heading shows the whole path, and so does the footer when the heading is too narrow for it.Filters. While a filter is on, the diff shows only the files it lets through, so
n/N,]/[andctrl+nmove among them:/filters by name. Every word must appear in the path; if no path has them all, the existing fuzzy rank is used instead. The list updates as you type,enterapplies the filter to the diff, andescclears it.topens a kind picker with a count for each kind: code, tests, docs, config, generated and other. Space turns a kind on or off, andentershows that kind alone.Hhides viewed files. A file you mark while they are hidden leaves the list, and the diff moves to the next file.Files · 12 of 340, with the filter on the line below it. The header counts and +/- totals cover only the files shown.The kinds for tests and generated files are ported from Plannotator's
packages/core/file-kind.ts(isTestPath,TEST_FOLDERS, the source-set and .NET test project rules,isDefaultGeneratedPath), and its test cases are ported too. On top of those rules, this PR also treats more lockfiles,*.pb.go,*.g.dart,vendor/,node_modules/anddist/(outsidesrc/) as generated..gitattributeslinguist-generatedis read as Plannotator reads it: onegit check-attr --stdin -zfor every path, on its own thread, whose answer wins both ways; a failure leaves the name rules. Docs, config and other are new here; a data or config extension wins over a documentation name (security.ymlis config).The new keys are documented in the keymap and its config action names (
filter-files,filter-kinds,hide-viewed,narrow-files,widen-files), the help overlay, the footer hints and the README. The list width has its own actions so a config that gave<or>to a code review key keeps loading and the reading column keeps its keys. The list keys also work over the whole-file view.Footer hints drop the least useful ones to fit one row, or two balanced rows on a narrow screen;
? helpandq quitstay.Which file the diff is in comes from the viewer's cursor, whatever moved it (a key, the notes rail,
d,ctrl+o, the mouse). diffs-rs names the file only on a line, so on a heading, a hunk heading or a binary file's note the cursor counts rows to the nearest lines above and below and comes back (review/diff/place.rs). AnEnginemethod for the cursor's file would make this one call.Large changes
With 3,000 changed files (release build,
cargo test --release -p plannotator-tui big_change -- --ignored --nocapture), rows, kinds and widths are cached:jin the diffjin the list/First paint is about 710 ms, most of it the review-progress identities that main computes too.
Not done
*.snap) count as tests, as in Plannotator, not as generated.Tests
cargo fmt --check,cargo clippy --workspace --all-targets -- -D warningsandcargo test --workspacepass. The new tests cover the kinds, the tree, the cuts, the width, the hint fitting and the patch sections as unit tests, plus flow tests inreview/tests/file_list.rs,file_moves.rs(the cursor's file,n/N, files without lines, type changes, filter cancel, narrow screens, hidden notes),file_list_mouse.rsandfile_kinds.rs. The review tests were run 10 times in a loop. The viewed-ticks test could start its edit before the disk watch had taken its baseline. That failed 4 times in 10 runs on this branch, while main passed 10 times in 10, so the new list's slower start brings out the race. The test now waits for the baseline, asdisk_flowdoes, and passed 10 times in 10.