Skip to content

perf(editor): eliminate syntax highlight flicker on documents >= 8KB (#1351) - #1458

Merged
ZhuchkaTriplesix merged 1 commit into
devfrom
issue/1351-highlight-flicker-patch
Oct 11, 2026
Merged

ZhuchkaTriplesix merged 1 commit into
devfrom
issue/1351-highlight-flicker-patch

Conversation

@ZhuchkaTriplesix

Copy link
Copy Markdown
Member

Closes #1351

Problem

In QueryaHighlightController, when editing documents where text.length >= kSyntaxHighlightIsolateThreshold (8192 characters / ~200 lines):

  1. On each keystroke, buildTextSpan previously saw _cachedText == text as false and fell back to plain monochrome text (TextSpan(style: style, text: text)).
  2. Only after kSyntaxHighlightDebounce (100 ms) did the worker isolate complete and call notifyListeners().
  3. As a result, typing in any script >= 8KB continuously flashed the editor between unhighlighted monochrome and highlighted text.

Solution

  • Introduced patchHighlightSegments in syntax_highlight_isolate.dart, which patches cached segments across untouched prefix and suffix ranges while inserting the edited region with zero latency.
  • Preserved syntax colors during active typing in documents >= 8KB in QueryaHighlightController instead of dropping to monochrome plain text.
  • Once the background isolate completes, segments and spans are seamlessly updated with exact grammatical tokenization without flicker or frame drops.
  • Added unit tests for patchHighlightSegments and verified that syntax styling is retained during live typing in large documents.

@github-actions github-actions Bot added editor Code/SQL editor performance Theme parser epic label: performance core Core library logic and services ui User interface components and widgets P2 Medium priority / Parity & Refactoring labels Oct 11, 2026
@ZhuchkaTriplesix
ZhuchkaTriplesix merged commit a2dfe8c into dev Oct 11, 2026
11 checks passed
@ZhuchkaTriplesix
ZhuchkaTriplesix deleted the issue/1351-highlight-flicker-patch branch October 11, 2026 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core library logic and services editor Code/SQL editor P2 Medium priority / Parity & Refactoring performance Theme parser epic label: performance ui User interface components and widgets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant