Skip to content

keep fold arrow clicks from being ignored after a tokenizer update - #19849

Open
kevinushey wants to merge 1 commit into
mainfrom
bugfix/ace-fold-widget-click-dropped
Open

kevinushey wants to merge 1 commit into
mainfrom
bugfix/ace-fold-widget-click-dropped

Conversation

@kevinushey

Copy link
Copy Markdown
Collaborator

Fixes #19848.

Intent

A click on a fold arrow in the editor gutter was ignored when it landed between a run of Ace's background tokenizer (about 700ms after a document's text or mode is set) and the gutter's next render. git_diff_gutter.test.ts "keeps a fold of added lines when its parent is expanded from the base pane" failed this way now and then.

Approach

Ace caches each row's fold widget in session.foldWidgets; a tokenizerUpdate empties the cache and the gutter refills it as it renders. Ace's gutterclick handler reads the cache without filling it in, so in between the row appears to have no widget.

A new acesupport mixin (acemixins/fold_widget_click.js) registers a capturing gutterclick listener on each new editor, which fills in the entry for the clicked row before Ace's handler reads it. No change to the Ace fork; the mixin can go once Ace fixes its handler (ajaxorg/ace#6035).

The click retry in the test's expandInBase helper worked around the same thing and is removed, so that the test fails if the fix stops working.

Automated Tests

  • code-folding.test.ts: fires the tokenizer's update and a click on a fold arrow in one task; fails without the mixin.
  • git_diff_gutter.test.ts: passes with plain clicks.
  • Measured with an instrumented copy of the failing test, sweeping the click time in 1ms steps around the tokenizer update: 24 of 111 clicks dropped before, 0 of 111 after.

QA Notes

Covered by the automated tests; the window is one animation frame, so it cannot be hit reliably by hand.

Documentation

None.

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 gutter click handler reads the session's fold widget cache, which a tokenizer update empties until the gutter next renders; a click in between was dropped. A capturing gutterclick listener now fills in the clicked row's entry first.

Addresses #19848
@kevinushey kevinushey added this to the 2026.12 (Parrot Balsam) milestone Nov 30, 2026
@kevinushey kevinushey self-assigned this Nov 30, 2026
@github-actions

Copy link
Copy Markdown

RStudio E2E - all platforms

1 test(s) failed

###################- 99% pass rate

Passed Failed Skipped Flaky
4474 1 201 1
Platform ✅ Passed ❌ Failed ⚠️ Skipped 🔁 Flaky
✅ auth-teardown 4 0 10 0
✅ desktop-linux 1499 0 49 1
❌ desktop-windows 1486 1 68 0
✅ server-linux 1449 0 54 0
✅ setup 36 0 20 0

View report online


All platforms - commit 3e4614562e7c149181a5743f9427c74bb6387037 - Run #2562

This branch has not been deployed

No deployments
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.

A click on a fold arrow in the editor gutter is occasionally ignored

1 participant