Skip to content

fix(editor): highlight the text an editor opens with, and go plain past the size limit - #4392

Merged
datlechin merged 5 commits into
mainfrom
fix/editor-highlight-size-cap
Nov 21, 2026
Merged

datlechin merged 5 commits into
mainfrom
fix/editor-highlight-size-cap

Conversation

@datlechin

@datlechin datlechin commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Summary

  • SourceEditor.makeController builds the controller with the bound text instead of "" followed by textView.setText. The SQL editor's coordinator loads the view inside the controller's init, so the highlighter was set up on "". Since perf: parse SQL off the main thread and shrink result rows #4340 the tree-sitter set up parses a snapshot taken at that moment, so it parsed "" and every query came back empty. Every editor that opened with text, such as a restored tab or a file tab at window open, stayed uncolored on 0.88.0-beta.2.
  • The NSTextStorage entry point still swaps storage after init, and now rebuilds the highlighter when the view is already loaded.
  • Highlighter treats maxHighlightableCharacters the same way however the document got there. An edit past the limit leaves the whole document plain. Before, the old colors stayed and the provider's tree missed the edits. An edit back under the limit sets the providers up again from the current text instead of applying edits to a stale tree. A document over the limit is never parsed or queried: HighlightProviderState sets its provider up only within the limit. A font or letter spacing change over the limit restyles the plain text without a query.
  • maxHighlightableLength is injected at init. HighlighterTests passes it there instead of setting it after.
  • Highlighter.setLanguage keeps the new language, so a provider set up later uses it.

Test plan

  • SourceEditorOpeningTextTests: bound text and a handed-over storage get highlights when a coordinator loads the view during init. Both fail on main, where the queries run against the tree for "".
  • HighlighterLengthLimitTests: at the limit the document is highlighted; one character over leaves it plain and forwards no edit; back under sets the provider up again and colors it; a font change over the limit restyles the plain text without a query; a document that opens over the limit is set up only once it comes under it.
  • Measured on the shipped 0.88.0-beta.2 in isolated sandboxes: restored tabs with 2K, 60K, 500K and 2M files and a two-line inline query all stay uncolored, while 0.87.0 colors the same 2K file. A Debug build of main under lldb shows the client's state committed with one set up and no edits, the whole document marked valid, and a single empty style run.
  • Not built locally (disk under the build floor). CI runs the package tests in the Unit plan.

@datlechin datlechin added the backport release/0.88 Merged into main; pick onto release/0.88 label Nov 21, 2026
@datlechin
datlechin enabled auto-merge (squash) November 21, 2026 08:58
@datlechin
datlechin merged commit b1a78be into main Nov 21, 2026
11 checks passed
@datlechin
datlechin deleted the fix/editor-highlight-size-cap branch November 22, 2026 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport release/0.88 Merged into main; pick onto release/0.88

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant