Skip to content

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

In review

Description

@kevinushey

Description

A click on a fold arrow in the editor gutter does nothing when it lands just after Ace's background tokenizer has run and before the gutter is next drawn (one animation frame).

The tokenizer runs about 700ms after a document's text or mode is set, so the window follows every document opening, and every refresh of the base pane in Show Changes Side by Side. It is narrow enough that a person rarely hits it, but the end-to-end tests do: git_diff_gutter.test.ts "keeps a fold of added lines when its parent is expanded from the base pane" fails this way now and then (both attempts in the desktop-linux run of #19836; once, passing on retry, on server-linux in #19790).

Cause

Ace caches each row's fold widget in session.foldWidgets. A tokenizerUpdate empties the cache from the first reported row on, and the gutter refills it as it renders. Ace's gutter click handler (ace/mouse/fold_handler) and its keyboard gutter handler read the cache without filling it in, so until the next render the row appears to have no widget and the event is dropped without an error.

Measured with an instrumented copy of the test: sweeping the click time in 1ms steps around the tokenizer update, 24 of 111 clicks were dropped, each with the cache empty at the time of the click, and none outside that window. Stock Ace (1.43.3 from cdnjs) does the same.

Fix

Fill in the cache entry for the row being acted on before Ace's handlers read it (an acesupport mixin), and report the bug to Ace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions