Skip to content

keep the git peek's close button clear of the editor scrollbar - #19587

Merged
kevinushey merged 5 commits into
mainfrom
bugfix/19576-peek-close-scrollbar
Nov 12, 2026
Merged

kevinushey merged 5 commits into
mainfrom
bugfix/19576-peek-close-scrollbar

Conversation

@kevinushey

@kevinushey kevinushey commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Intent

Fixes #19576.

In a document long enough to scroll, the close button (×) of a Git change opened from the editor gutter, and of its action bar in the side-by-side view, could not be clicked when scrollbars take up no room, as macOS's overlay scrollbars do (the default with a trackpad). The click landed on the editor's scrollbar instead. Escape still closed it.

This is what fails "keeps the sides level with the action bar open by a chunk's output" in git_diff_gutter.test.ts on macOS. The issue guessed that full-width scrollbars were the trigger; it is the other way round. The test passes with full-width scrollbars (Linux CI, or a Mac with a mouse connected) and fails with overlay scrollbars.

Approach

The bar is an Ace line widget with fixedWidth: true, which Ace ends where the room it keeps for the vertical scrollbar starts (scrollBar.getWidth()). The scrollbar's element is wider than that room: Ace makes it (width || 15) + 5 px wide, so it overlaps the widget by 5px with 15px scrollbars, and by all 20px when the measured scrollbar width is 0. The close button sits 8px from the widget's end, which clears 5px but not 20px.

GitDiffGutter now gives the close button a right margin equal to that overlap whenever the vertical scrollbar is showing, and takes it away when the scrollbar goes. It runs when the peek opens and on each render (the scrollbar comes and goes with the document's height); the overlap is read from the width Ace set on the element's style, so nothing is measured per frame.

Two consequences worth knowing:

  • With full-width scrollbars the button moves 5px to the left of where it was (it is now 8px clear of the scrollbar's element in both styles, where it was 3px clear).
  • In a narrow editor the peek's label can wrap around the moved button, which makes the peek taller. The peek is handed back to Ace to measure when the margin changes, so the lines below it stay below it. The side-by-side action bar has no label, so it is left alone (and its row accounting with the alignment padding is untouched).

The fix is in the peek rather than in Ace: with overlay scrollbars Ace means content to run under the scrollbar, and the widget's background still does. Only the control at its end needed to move.

Automated Tests

src/gwt/test/git_diff_test.html (run by ant testpage, in headless chromium, where scrollbars take no room) gains checks on a real editor and gutter:

  • with the scrollbar showing, the close button is clear of the scrollbar's element and is what a click at its centre hits;
  • the margin goes when the editor grows tall enough to lose its scrollbar, and comes back with it;
  • in an editor narrow enough for the margin to wrap the label, the room the peek reserves covers its new height.

The first and third fail without the change.

The e2e test named in the issue needs overlay scrollbars to fail, which depends on the machine. Run locally on macOS with test:desktop-dev, forcing them for the Electron process:

PW_RSTUDIO_EXTRA_ARGS="-AppleShowScrollBars WhenScrolling" npm run test:desktop-dev -- tests/panes/editor/git_diff_gutter.test.ts

Before the change that test fails with the error in the issue; after it, the whole file passes with overlay scrollbars and with full-width ones.

QA Notes

On macOS, set System Settings > Appearance > Show scroll bars to "When scrolling" (or use a trackpad with no mouse connected and the default "Automatically based on mouse or trackpad").

  1. Open a file in a Git repository that is longer than the editor is tall, and change a line.
  2. Click the marker in the gutter beside the change. Click the × at the right end of the box that opens: it closes.
  3. Tools > Version Control > Show Changes Side by Side, click the marker again, and click the × on the bar: it closes.

Before the fix the × did nothing in steps 2 and 3. With "Always" selected for scroll bars, both worked before and still do.

Documentation

None needed.

Checklist

  • If this PR adds a new feature, or fixes a bug in a previously released version, it includes an entry in NEWS.md
  • If this PR adds or changes UI, the updated UI meets accessibility standards
  • A reviewer is assigned to this PR (if unsure who to assign, check Area Owners list)
  • This PR passes all local unit tests

Ace's vertical scrollbar element is wider than the room Ace keeps for it (by all 20px with overlay scrollbars), so it covered the close button at the end of the peek and took its clicks.

Addresses #19576
@kevinushey kevinushey added this to the 2026.12 (Parrot Balsam) milestone Nov 11, 2026
@kevinushey
kevinushey requested a review from gtritchie November 11, 2026 23:57
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

RStudio E2E - all platforms

All tests passed!

#################### 100% pass rate

Passed Failed Skipped Flaky
5365 0 241 7
Platform ✅ Passed ❌ Failed ⚠️ Skipped 🔁 Flaky
✅ auth-teardown 4 0 15 0
✅ desktop-linux 1401 0 46 2
✅ desktop-macos 1176 0 39 2
✅ desktop-windows 1396 0 57 2
✅ server-linux 1342 0 54 1
✅ setup 46 0 30 0

View report online


All platforms - commit 3f5fae8d8ea85136a57d3c72d0cf9144c76948c4 - Run #2237

@gtritchie gtritchie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix itself checks out against Ace's scrollbar and line-widget code. The requested changes are to NEWS.md; the rest is smaller.

NEWS.md (pre-existing, but it sets the release boundary this entry relies on). The 2026.12.0 ### New section (lines 7-12) repeats all six ### New entries of 2026.11.0 (version/news/os/NEWS-2026.11.0-montauk-daisy.md on rel-montauk-daisy):

  • #19166, #19114 and #19142 match the 2026.11 entries word for word, so they can go.
  • #12622, #2846 and #19208 are the 2026.11 entries edited in place after the branch (by #19158 and #19350) to describe follow-up work. As written, the 2026.12 notes present the gutter markers and the side-by-side view as new again. Each could become an entry for just what 2026.12 adds: the status-bar change count, the Git pane go-to-change button, the toolbar toggle, the pane headers and the side-by-side revert bar, and, for #12622, the install destination confirmation and the nearby-version alternative.

Could you fix those here, or in a separate PR?

Comments are inline.

Comment thread NEWS.md Outdated
- ([#19241](https://github.com/rstudio/rstudio/issues/19241)): The Console notice shown at startup when RStudio reduces background file operations for a project can now be turned off with the `show_reduced_file_operations_notice` preference (e.g. from the Command Palette), or for all users by an administrator with `"show_reduced_file_operations_notice": false` in `rstudio-prefs.json`.

### Fixed
- ([#19576](https://github.com/rstudio/rstudio/issues/19576)): Fixed an issue where the close button of a Git change opened from the editor gutter, or of its action bar in the side-by-side view, could not be clicked in a document long enough to scroll when scrollbars take up no room (as macOS's overlay scrollbars do): the editor's scrollbar area covered it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only half of this is a released bug. In 2026.11 (rel-montauk-daisy) the gutter peek has its close button at the end of the header (margin-left: auto, fixedWidth: true), so that part shipped. The side-by-side action bar came in #19350 (dd65ab2, 2026-11-04), after the branch; in 2026.11 a side-by-side marker click only moves the cursor. Per the repo's CLAUDE.md, fixes to unreleased features don't get a NEWS entry, so please drop "or of its action bar in the side-by-side view".

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. In 2026.11, showPeek returns early whenever a side-by-side view is attached, so the action bar never shipped. Dropped in 5d8ab12.

// and the peek's height follows; Ace measures it again in this frame.
// (The action bar has no label to wrap.)
peek.headerHeight = null;
if (!peek.compact)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This remeasures the peek when the scrollbar cover changes, but the label also wraps when the editor's width changes (dragging the pane splitter), and nothing remeasures it then. Ace's measureWidgets only measures widgets in _changedWidgets, and RStudio's syncLineWidgetHeights only runs from AceEditor.setFontSize. So rowCount stays at the old height and the taller peek overlaps the lines below it.

That gap predates this PR, but the new test works around it: git_diff_test.html calls onWidgetChanged(peekWidget) itself after narrowing #live (line 262). Calling onWidgetChanged for a non-compact peek from pinPeek whenever peek.headerWidth !== scrollerWidth (the check it already does) would cover resizes and the scrollbar case together, and the test wouldn't need the manual call.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed; fixed in 2ca2bce. The check is now fitPeek. It compares the scrollbar's cover and $size.scrollerWidth with what the peek was last laid out for, and hands a non-compact peek back to Ace when either changes. It still runs from pinPeek, and also from a capturing beforeRender listener ahead of measureWidgets. Since onResize updates scrollerWidth before it renders, a resize is measured in the render that lays it out. pinPeek's header-height cache no longer tracks the width itself; fitPeek resets it.

The testpage no longer calls onWidgetChanged itself. It now widens and narrows the editor through the render loop and checks rowCount one frame later; the widening check fails without the change.

Comment thread src/gwt/acesupport/git_diff_gutter.js Outdated
peek.closeButton.style.marginRight = (cover > 0) ? cover + "px" : "";

// In a narrow editor the label wraps around the button's new place,
// and the peek's height follows; Ace measures it again in this frame.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Ace measures it again in this frame" holds only for synchronous renders (e.g. resize(true)). When this runs from pinPeek during a render-loop pass (typing, scrolling), RenderLoop._flush has already set pending = false, so updateFull() -> $loop.schedule calls requestAnimationFrame again, and measureWidgets runs in the next frame. One frame is painted with the old rowCount, so a freshly wrapped label briefly overlaps the line below. Either the comment should say so, or the fix above (remeasuring before the widgets are positioned) avoids it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. With the beforeRender hook in 2ca2bce, resizes are measured in the same render. A scrollbar that appears or goes, or a gutter that changes width, still changes during the render ($computeLayerConfig, onGutterResize), after measureWidgets has run. Those are queued from pinPeek and measured in the next frame. The comment on fitPeek now says one frame shows the old height in that case.

Comment thread src/gwt/acesupport/git_diff_gutter.js Outdated
this.lineWidgetManager().addLineWidget(widget);
this.peek = { chunk: chunk, widget: widget, compact: compact };
this.peek = { chunk: chunk, widget: widget, compact: compact, closeButton: closeButton };
this.clearPeekOfScrollbar();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: addLineWidget has already measured the widget and queued onWidgetChanged by this point. Because scrollBarCover starts out undefined, this first call always queues a second one, even when the cover is 0. Setting closeButton.style.marginRight while building el would let Ace's first measurement include the margin, and the first-call case would go away.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 2ca2bce. showPeek sets the margin before addLineWidget and records the cover and width on the peek, so the first fitPeek finds nothing changed.

// scrollbars take no room (as in this runner's headless chromium, and
// with macOS's overlay scrollbars), and would take the clicks meant
// for the close button there (#19576).
review.dispose();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These checks close the side-by-side view first, so the compact action bar, the case the e2e test in the issue fails on, has no testpage coverage. A check with review attached (close button clear of the scrollbar and taking clicks, with the alignment padding unchanged) would cover the compact branch of clearPeekOfScrollbar without depending on the machine's scrollbar style.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in 2ca2bce, with the side-by-side view attached: a deletion at the end of the document, whose bar takes on the 3 rows of padding. It checks that the close button is clear of the scrollbar and takes clicks, before and after the scrollbar goes and comes back, and that the bar keeps its rows and the sides stay level. Removing the !peek.compact guard fails the padding and level checks.

editor.resize(true);
await rendered();
var spare = closeButton.getBoundingClientRect().left - revertButton.getBoundingClientRect().right;
live.style.width = (live.offsetWidth - spare + 10) + "px";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: live.style.width and label.style.lineHeight are never restored (only live.style.height is). Nothing runs after this block today, but a check added later would start with a narrowed editor and a wrapped peek. Resetting the width and calling editor.resize(true) at the end would avoid that.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 2ca2bce. The block now resets the label's line height and the editor's width and renders again at the end.

The label also wraps when a pane is resized, and nothing measured the peek then. The check now runs ahead of Ace's measureWidgets as well as after the render, so a resize is measured in the render that lays it out, and the close button's margin is set before Ace first measures the widget. The testpage covers the side-by-side action bar and restores the editor's width and the label's line height.

Addresses #19576
@kevinushey

Copy link
Copy Markdown
Collaborator Author

Thanks for catching these. They don't touch this fix, so I'll clean up the 2026.12 ### New section in a separate PR: drop #19166, #19114 and #19142, and cut #12622, #2846 and #19208 down to what 2026.12 adds.

@gtritchie gtritchie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. All six inline points are addressed. Fixing the 2026.12 NEWS duplicates in a separate PR is fine.

@kevinushey
kevinushey merged commit 07cb6f9 into main Nov 12, 2026
13 of 15 checks passed
@kevinushey
kevinushey deleted the bugfix/19576-peek-close-scrollbar branch November 12, 2026 21:54
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.

e2e: side-by-side action bar close button covered by the scrollbar on macOS (chunk output test)

2 participants