Repository navigation
git change review: toolbar toggle, revert bar, pane headers, go-to-change - #19350
Conversation
…ange Follow-ups to the editor gutter markers (#2846) and the side-by-side view (#19208): - Side by side, a marker click (or Show Change at Cursor) opens a compact bar with Revert and Close under the change, with the base pane padded to keep the sides level; it used to only move the cursor. - Headers name the two sides: "Before: Index (last staged or committed)" and "After: Working tree (your current edits)". - The editor toolbar gains a latching toggle for the side-by-side view, with an icon of its own (and a dark-theme variant hook), shown for documents in Git projects with the markers on. - Each file in the Git pane gets a button that opens it at its first change: the first unstaged one, else the first staged one. - Modified lines are marked with a solid blue bar instead of a dashed one, drawn 3px wide like the others (the background shorthand had reset background-clip, doubling it). - The Git changes table themes every header cell, not only sortable ones. Addresses #19208.
RStudio E2E - all platforms3 test(s) failed
View / download the full reportView report online -- opens in the browser, no download needed. Available for 14 days. Download playwright-report.zip -- extract and open
All platforms - commit |
A peek opens below its change, so for a change taller than the editor a marker click seemed to do nothing: the peek (or side-by-side action bar) landed out of view. Its header is now drawn at the bottom of the editor, like a sticky footer, while the change's first line is on screen; it scrolls into its own place, and out at the top, as the editor scrolls down, and leaves with the change's first line when scrolling up. The clamp runs in the same render pass that positions the widget, and the pinned and natural positions coincide where pinning starts, so the header never jumps. While pinned it is opaque, with a shadow above it. Addresses #19208.
The editor status bar gains Previous and Next Change buttons, left of the
file type selector, around a count of the document's Git changes:
"Change 2 of 3" on a change, "3 changes" between them, "No changes" (with
the buttons disabled) when the file matches the index. It is shown while
the gutter markers have a base to count against -- a Git project with the
preference on, a tracked file -- and hidden in visual mode.
- The gutter reports when the change at the cursor or the number of
changes may have moved (edits, cursor moves in either side-by-side
pane, focus changes), batched per task.
- An open peek, or the side-by-side action bar, follows Next and
Previous Change to the change navigated to.
- A click brings focus to the editor, as a marker click does; from the
keyboard, focus stays on the button for the next step.
- Where the cursor lands is announced ("Change 2 of 3"), as a new
aria-live announcement that can be turned off like the others.
Addresses #19208.
… and peek scrolling - The Git pane's go-to-change button lands on a deletion's marked line (the line after it), honors the ignore-whitespace preference, resolves a staged rename within a subdirectory against the repository root, and opens a file the editor can't take as text (an .rds) as Open would. - Side by side, the action bar at a deletion at the top of the file takes on the padding above the first line, which had nowhere else to go, so the sides stay aligned while it is open. - A peek on a single line wrapped taller than the editor pins to the bottom edge like any tall change. - Next/Previous Change closes an open peek before scrolling, so the rows it took no longer carry the destination off screen. Addresses #19208.
…newline - A diff that gives up or fails marks nothing, which the status bar no longer reports as "No changes": the count is hidden until a diff comes through again. - The Git pane's go-to-change button lands on the empty last line the editor marks when only a final newline was added, rather than on the line Git shows as replaced. Addresses #19208.
- Next/Previous Change with a peek open swaps the peeks, and realigns a side-by-side view around them, before scrolling; the scroll no longer misses a deletion's peek opening above it, or the padding above the first line coming back as the action bar leaves a deletion at the top. - The Git pane's go-to-change button resolves a staged copy's path, which Git reports as a rename is. Addresses #19208.
…at the end - Next/Previous Change with a peek open scrolls without animation, so the check that keeps the change in view no longer stops a smooth-scrolling animation where it started. - The Git pane's go-to-change button skips the lines the editor sees as unchanged at the head of an end-of-file hunk, however many newlines were added after an unterminated last line. Addresses #19208.
Next/Previous Change with a peek open realigns a side-by-side view again after going to the change, which can unfold lines around it, so the padding for a change in a folded region no longer lands after the check that keeps the change in view. Addresses #19208.
…p deletion's bar - Next/Previous Change unfolds the change, swaps any open peek, and has a side-by-side view realign, all before deciding whether to scroll, and decides from where the rows are now (rather than as gotoLine does, from the rows last drawn); a change in a folded region, peek or not, no longer ends up off screen. The scroll stays animated where smooth scrolling is on. - Side by side, the action bar of a deletion at the top of the file is held up to the bottom of the view while the padding standing in for the removed lines is on screen, as a tall change's peek is. - The Git pane's go-to-change button counts no empty last line for an empty file. Addresses #19208.
The Git pane's go-to-change button opens the file at the line Git reports, as before, and then moves on to the first change the document's own gutter markers show, once they are current. The two can differ: an unsaved edit in the open document, blank lines added after a final newline, and the other end-of-file and whitespace cases. With the markers off, or the cursor moved meanwhile, Git's line stands. This goes through a new navigation method (GIT_FIRST_CHANGE), so it works wherever the document opens, a source window included. Addresses #19208.
…igation ends - A go-to-change request that arrives before the document's gutter has attached (the diff support still loading) now waits out the gutter's first base fetch, rather than being settled, empty, as the gutter took up the document's path. - The move to the editor's first change starts once the navigation is done, which in visual mode can take a switch to the source editor; a document still in visual mode stays put. - Next/Previous Change scrolls back to the start of the line gone to, for an editor scrolled sideways. Addresses #19208.
…nges-toolbar-button # Conflicts: # src/gwt/src/org/rstudio/studio/client/application/StudioClientApplicationConstants.java # src/gwt/src/org/rstudio/studio/client/application/StudioClientApplicationConstants_en.properties # src/gwt/src/org/rstudio/studio/client/application/StudioClientApplicationConstants_fr.properties
…e pane - The Git pane's follow-up to the editor's first change stands down if the user has moved on while it waited: either cursor moved, or focus changed panes side by side, or (for a document whose gutter was still attaching) the document's cursor moved before it attached. - Escape closes the action bar from the base pane too, which can hold focus while the bar is open. Addresses #19208.
… first fetch - Side by side, the action bar of a deletion goes below the line the marker is on, past the padding for the removed lines, as it did at the top of the file already, and is held up to that padding like a tall change's peek; a deletion taller than the editor no longer opens its bar out of view above. - Padding that cannot move off the bar's row (chunk output on the row next to it, say) is taken on by the bar, below as well as above its line, so the sides stay level. - A go-to-first-change request made before the gutter attaches makes the gutter's first base fetch itself, rather than a second one. Addresses #19208.
…-output bar after its padding - A new base fetched for the Git pane's go-to-first-change replaces the base pane's text, which takes its cursor to the top; that no longer reads as the user moving on, and the follow-up goes to the first change. A later request supersedes an earlier one. - Side by side, the action bar of a deletion just before a line holding chunk output, which takes on the padding for the removed lines below its own line, is drawn after that padding, by the marked line, and held up to the padding's top like the bar below the marked line; a deletion taller than the editor no longer leaves it out of view. - The e2e base-fetch tracker's settled() waits for the fetches' answers, so the follow-up cancellation test sees the released fetch through. Addresses #19208.
- Side by side, the padding for lines removed just after a line holding chunk output, which goes above the next line instead, is taken on by the action bar when that line holds it, rather than dropped; the sides stay level with the bar open. - The bar is held up to the top of padding it took on above its line, not to the bottom of the line before (and its output). Addresses #19208.
Ace has a widget at the end of a fold stand at the fold's start too. With the action bar so folded, padding landing on one of its rows was passed to the other and back until the stack ran out (a function's changed closing line, folded, with a base header that wraps onto more rows). Padding moves onto the bar only from another widget's row. Addresses #19208.
Padding landing within a fold had Ace's fold handling run again for the whole fold, which hides the widget Ace has already stood at the fold's first row: a folded change's action bar went out of view once wrapping padded inside the fold. The padding gets the same treatment on its own (hidden within the fold, or at its first row from its last), and other widgets are left as they are. Addresses #19208.
gtritchie
left a comment
There was a problem hiding this comment.
Review of the code changes (not the e2e test file); nothing was built or run. Eight findings, inline. The one most likely to be a user-visible bug is the staged-rename case in GitPresenter.findFirstChange. The Git pane Tab stops and the fixed-height diff headers are confirmed from the code. The rest are lower-confidence or cleanup, and each comment says which.
| CommandWithArg<Integer> onFound) | ||
| { | ||
| server_.gitDiffFile( | ||
| item.getPath(), |
There was a problem hiding this comment.
For a staged rename (status R ), item.getPath() is old -> new. vcsDiffFile keeps only the new path (splitRename(path, nullptr, &path), SessionGit.cpp:2219) and runs git diff --cached -- <new>. With the old path outside the pathspec, Git can't pair the two sides, so the diff should show the whole file as added (@@ -0,0 +1,N @@).
Result: stage a git mv that also edits a line in the middle, then click go-to-change. The working diff is empty, the staged diff points at line 1, and the gutter (working tree vs index) has no chunks to correct it, so the file opens at the top. I couldn't run this in a scratch repo, so please confirm. A possible fix is to pass both paths for R /C in Stage mode (doDiffFile already takes a pCompareTo).
There was a problem hiding this comment.
Confirmed in a scratch repo: git diff --cached -- new.R shows the renamed file as @@ -0,0 +1,N @@. Fixed in d99a47a: diffFile takes the old path for a staged rename and passes both in the pathspec. This also gives the Review Changes window the rename's own hunks for a staged rename; its unstage path emits the new path on both sides of the patch, so that keeps working. Test in 395cfc0 (a staged rename with a changed line opens at that line).
| return; | ||
|
|
||
| ImageResource2x icon = new ImageResource2x(CodeSearchResources.INSTANCE.gotoFunction2x()); | ||
| sb.append(SafeHtmlUtil.createOpenTag("button", |
There was a problem hiding this comment.
Each row's go-to-change button is a native <button> with no tabindex, so the changes table gains one Tab stop per file. Before this, the table was a single Tab stop: rows are reached with the arrow keys, and the staging checkbox is a non-focusable <img role="checkbox"> (TriStateCheckboxCell.java:154) worked with Space. With 200 changed files, Tab now needs about 200 extra presses to get past the table.
The repo's .claude/CLAUDE.md says "Changes to existing UI should not make accessibility worse." Following the table's own pattern would avoid it: tabindex="-1" on the button, plus a key on the focused row (as Space does for staging).
There was a problem hiding this comment.
| private GitDiffSplitNative view_; | ||
| private Command focusHandler_; | ||
|
|
||
| public static final int HEADER_HEIGHT = 22; |
There was a problem hiding this comment.
The Before/After headers are a fixed 22px tall (this constant, the addNorth(..., HEADER_HEIGHT) in TextEditingTargetWidget, and height: 22px; line-height: 21px; overflow: hidden at themeStyles.css:3718). Their text, though, takes the editor font size through FontSizer's normalSize class (font-size: Npt !important). At an 18pt editor font (24px) the text is taller than the box and gets clipped. The two headers may also clip differently: the base header keeps its own 21px line-height, while the live header carries normalSize itself and so gets that rule's percentage line-height.
Sizing the header from its content (e.g. a min-height plus padding), and giving the base editor's offset and the live side's north panel the measured height, would avoid both.
|
|
||
| // ApplicationThemes applies the new theme's classes in a handler of its | ||
| // own, registered first, so the theme is current by the time this runs | ||
| releaseOnDismiss_.add(events_.addHandler(ThemeChangedEvent.TYPE, event -> |
There was a problem hiding this comment.
Minor: diffSideBySide_2x.png and diffSideBySideDark_2x.png are the same blob (5601e8db833c), so for now this handler, diffSplitIcon(), RStudioThemes.isDarkTheme() and the dark ImageResource swap an image for itself. I know the description says a real dark icon is coming. I'd drop this until it does, so the new public theme API arrives along with something that uses it.
There was a problem hiding this comment.
Keeping this as is: a proper dark icon should land soon, and I'd rather not take the swap out only to put it back.
| } | ||
|
|
||
| if (this.splitView) | ||
| this.goToChunk(chunk); |
There was a problem hiding this comment.
Cleanup, low confidence of a visible bug: togglePeek is now the only caller of goToChunk. goToChunk scrolls with gotoLine / goToBaseRow before showPeek adds the compact bar and the view realigns, which is the ordering goToChange was written to replace. In practice a clicked marker's row is already on screen, so I haven't seen it misplace anything.
This order would let goToChunk go and leave one navigation path to maintain:
this.showPeek(chunk);
if (this.splitView)
this.goToChange(chunk);(goToChange skips re-showing the peek because peek.chunk === chunk, then realigns, moves both cursors, and reveals the row.)
There was a problem hiding this comment.
Tried this order; the e2e "shows the action bar by a chunk's output against the line it marks" fails with it: the bar's header ends up 90 lines above the fence rather than against it, since goToChange realigns after the bar has taken on the padding for the removed lines. The original order passes, so I've kept goToChunk.
| // newline as an empty line after it) leaves it alone. Such a hunk ends at | ||
| // the end of the file on both sides, and a "\ No newline at end of file" | ||
| // note follows the side whose last line has none. | ||
| private static int unchangedLeadingLines(DiffChunk chunk) |
There was a problem hiding this comment.
Design note, not a defect: unchangedLeadingLines repeats, in Java, the gutter's end-of-file newline handling (displayRow / update in git_diff_gutter.js). With the markers on, GIT_FIRST_CHANGE moves on to chunks[0] anyway, so this prediction only matters with the markers off (the button is still shown then) or for staged-only changes. That's a reason to keep it, but it leaves two places to keep in step: if either changes, the line opened with the markers off drifts. A comment on each side pointing at the other would help.
| { | ||
| event.stopPropagation(); | ||
| if (handler_ != null) | ||
| handler_.onNavigate(next, clickCount(event.getNativeEvent()) > 0); |
There was a problem hiding this comment.
Unverified: fromPointer comes from event.detail > 0, which isn't used anywhere else in src/gwt. Some assistive technology activates a button with a simulated mouse click, which can carry detail 1. If so, a screen-reader user's Next Change would send focus into the editor and lose their place on the button. A flag set from the button's own pointerdown (cleared on click) would separate mouse from keyboard and AT without relying on detail.
There was a problem hiding this comment.
Fixed in f188998: a mousedown on the button sets a flag the click consumes (cleared on keydown), so a click without one, from the keyboard or AT, leaves focus where it is.
| if (floor != null) | ||
| { | ||
| var header = el.firstChild; | ||
| height = el.clientTop + header.offsetTop + header.offsetHeight; |
There was a problem hiding this comment.
Minor perf, not profiled: while a peek is open below an added or modified change, pinPeek reads clientTop / offsetTop / offsetHeight on every afterRender, usually just after Ace has written widget styles. That can force a synchronous layout on each scroll frame. The header's height doesn't change once the peek is built, so measuring it once in showPeek and caching it on this.peek would avoid the reads.
There was a problem hiding this comment.
Fixed in 37b7cb2: the header is measured once per peek, re-measured only when the editor's width changes.
With the new path alone in the pathspec, Git cannot pair the two sides of a staged rename and shows the file as added whole, so the Git pane's go-to-change opened a renamed file at the top rather than at its first staged change.
…order The table stays one Tab stop, as before the buttons; the selected row's change is gone to with Ctrl+Enter (Cmd+Enter on a Mac). Also notes, by the Git pane's prediction of the first changed line, the gutter code it must agree with.
The Before/After headers were a fixed 22px, which an editor font larger than the default overflowed. The base pane now measures its header and lays its editor out below it, and the live side takes the same height; both follow font size changes.
pinPeek runs on every render; reading the header's offsets there forced a layout each frame. Also notes, by splitLines, the Git pane code that predicts where the gutter puts a first change.
Rather than by the click event's detail, which assistive technology's simulated clicks may set; a click without a mousedown leaves focus where it is.
… the header height
A command for what a row's go-to-change button does, enabled for a single selected file with something to open, so the row's menu offers it beside Open File.
…rst change Ctrl+Enter / Cmd+Enter never reached the changelist table with a script open: ShortcutManager previews every keydown and executeCode, enabled by the active document, took the key. Nothing binds Shift+Enter globally. The e2e test now opens an untitled script first, so the key is pressed with executeCode enabled; the shortcut reference lists the key.
With status.renames=copies a copy is listed as 'source -> copy', and its staged diff took both paths, so a source with staged changes of its own came first and was taken for the copy's. The diff now asks Git to pair the copy with its source (-C) and keeps the pair whose new side is the requested path. Unit test for the filter; the e2e copy has a changed line and sorts after its source.
An earlier request still out for its diff (or its staged fallback) could open after a later one. Open at First Change's enablement is also recomputed after a refresh and before the context menu shows, as a refresh can change what the selected file allows.
…hanges The header's cached height was keyed on the editor width alone, so a font or line height change left it clipped until the peek reopened.
Its mousedown flag stayed set, so the next click without one (from assistive technology) read as a pointer's and moved focus to the editor.
--diff-filter=CR with -C drops the source's own staged changes from the diff of a staged rename or copy, in place of parsing the pairs out of the output (which missed an identical copy, with no +++ line, and quoted names).
The gutter (line numbers toggled, say) takes from the width the header has without changing the editor's.
Clearing the mousedown flag on mouseout read a press that left the button and came back to be released on it as a keyboard click. The release is watched instead: one off the button clears the flag, one on it leaves it for the click.
The pathspec for a source a directory took the name of brings that directory's other renames and copies along; the pair is picked out by its 'rename to' or 'copy to' line, with core.quotepath off so that the path reads as given.
The gutter listened for afterRender before a widget manager made after it, so pinPeek could measure the header with the previous frame's left edge (the gutter's width, as line numbers come and go) and cache that.
Double quotes, backslashes and control characters in a name are escaped in the diff even with core.quotepath off.
gtritchie
left a comment
There was a problem hiding this comment.
Shift+Enter fixes the Run Current Line clash, and the test now covers it with a script open. The other new commits check out too. The branch conflicts with main, so it needs a merge or rebase before it can land.
Follow-up to #19208 (side-by-side view) and #2846 (gutter markers), from hands-on testing of the new Git integration.
Changes
ThemeChangedEventas the Assistant toggle's is; for now it is the same image, to be refined later.backgroundshorthand resetbackground-clip.Notes
Testing
e2e/rstudio/tests/panes/editor/git_diff_gutter.test.ts(server mode): 66 passed. Updated the side-by-side test for the action bar, and added tests for the toolbar toggle and headers, reverting from the action bar, the Git pane button, the status bar navigator (count, stepping with wrap-around, announcement, mouse and keyboard focus, the peek following, hidden with the preference off and for untracked files, "No changes"), and pinning: a 120-line change scrolled in 11px steps both ways, checking at each step that the header is either pinned to the bottom edge or moving with the text, never jumping, then pinned side by side and reverted from there.