Repository navigation
perf(editor): scan a large script's run controls off the main thread - #4571
Merged
Merged
Conversation
The gutter's run controls rescanned the whole document on the main actor after each typing pause, 31 ms at the size limit, and on first open, a replaced document and a grammar change. Above the synchronous limit the scan now runs in a @Concurrent function on a snapshot taken on the next turn of the main actor, and its result is dropped if an edit, grammar or statement model change landed meanwhile. Keyword auto-case lexed from offset 0 to the caret to tell whether a word sits in a literal or comment. It now reads from the start of the caret's statement, which SQLStatementCursorIndex keeps and which never lies inside one, and asks for it only once the word is a keyword in the wrong case.
datlechin
enabled auto-merge (squash)
November 26, 2026 01:50
…-index # Conflicts: # apple/TablePro/Views/Editor/StatementRunController.swift
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.
Summary
@concurrentfunction, and replaces the controls only if no edit, grammar change or statement model change landed meanwhile. The same path serves first open, a replaced document and a grammar change, which also scanned the whole document on the main thread.SQLStatementCursorIndexalready keeps: a statement never starts inside a literal or comment. The start is asked for only once the word is a keyword in the wrong case, so a plain word boundary costs nothing more than before.Measured:
Test plan
StatementRunControllerTests: a large document's controls arrive from the background scan and equal a fresh scan, with nothing assigned on the call itself; a refresh asked for before an edit reads the edited text; the keyword-case statement start equals the scanner's and costs one checkpoint span, and another grammar gets 0.KeywordUppercaseHelperTests: reading from a statement start gives the same answer as reading from the top.This PR and #4562 both touch
StatementRunController.scheduleControlsRefresh; whichever merges second takes a one-line merge.Closes #4534