Repository navigation
fix(review): saving a note keeps the diff where it was - #201
Merged
Merged
Conversation
Saving the first comment opened the notes panel, the diff got narrower, and diffs-rs scrolled every line sideways to the column the mouse selection had last clicked. That click was at the new side's right edge, so a wide split left only the tails of long lines, and nothing in the review scrolls back. - Selection clicks land left of the code, and after any click in the diff the row is clicked again there, so the viewer never holds on to a code column. Opening or closing the notes or the file list, resizing, moving the line between the sides or changing the layout keeps each line's code where it was. - In the code review a saved note no longer opens the notes panel: `when-notes` is decided when the review opens. The note still gets its gutter mark, the footer says "note saved" and "notes hidden: z shows them", and the header's Send counts it.
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.
Problem
In a wide split diff with long lines (for example the middle line at 30:70, wrap off, file list open, notes panel closed), saving the first comment on a mouse selection opened the notes panel. The diff got narrower, and every line was scrolled sideways: line numbers stayed, but only the tails of the longest lines were left. The review has no way to scroll back.
Cause
diffs-rs remembers the column a click lands on. When the pane next changes width it reflows and, if that column is no longer in view, makes it the first column shown (
render::anchored_position, called fromApp::reflow_from).Diff::select_in_placemakes a mouse selection by clicking both ends atarea.right() - 2, the new side's right edge. After the release the remembered column was about 100 cells into the line. The notes panel then took about 37 columns, the new side became narrower than that column, and the viewer scrolled to it.A plain click far right in the code, followed by
z,f, a resize or(/), did the same.Fix
select_in_placeclicks left of the code, on the side's first column.Diff::forget_columnclicks the same row again on that column, if the cursor is on code there (wrap off). The cursor, the side and the selection do not change. The viewer's remembered column is then the one already shown first, so a later width change keeps each line's code where it was.when-notesis decided once, when the review opens: with notes the panel shows, without notes it stays away untilzorTab. The saved note still gets its gutter mark, the footer saysnote savedandnotes hidden: z shows them, and the header's Send counts it. If the panel is already open, it stays open and shows the note. The document review is unchanged. The README says this now.Tests
review::tests::save_keeps_view(new): a 190x50 terminal, split 30:70, wrap off, long lines, list open, panel closed, three wheel notches.c, type,Enter. The rows and each line's code column are the same before the box opened and after the save, and the panel stays closed.vselection, a suggestion and a cancelled box.zopen and close,fclose and open, a resize, and(/).All three tests fail on
mainand pass here.Tests that relied on the panel opening by itself now open it with
z.Engine note
The workaround is in this app. In diffs-rs,
anchored_position(src/render.rs) turns a remembered click column into the horizontal offset when a reflow narrows the pane. A host that offers no horizontal scrolling would need either a way to keep the offset or one to clear the remembered column.