Skip to content

perf(editor): eliminate syntax highlight flicker and fallback to plain text on documents >= 8KB in QueryaHighlightController #1351

Closed

Description

@ZhuchkaTriplesix

Summary

In lib/core/editor/querya_highlight_controller.dart (lines 40–82):
When editing documents where text.length >= kSyntaxHighlightIsolateThreshold (8192 characters / ~200 lines of SQL):

  1. On each keystroke, buildTextSpan checks:
    if (_cachedSpan != null && _cachedText == text)
  2. Because the user just typed a character, text changed and _cachedText == text is false.
  3. The method falls through to:
    return TextSpan(style: style, text: text);
    which returns completely unhighlighted, plain monochrome text.
  4. Then _debounceTimer waits 100 ms (kSyntaxHighlightDebounce), launches the isolate highlight job, and once completed, updates _cachedSpan and calls notifyListeners().

As a result, while typing in any script >= 8 KB, the entire editor visibly flashes to monochrome plain text on every keystroke, and only flashes back to highlighted colors 100+ ms after the user pauses typing. If the user types continuously, all syntax highlighting is completely lost during typing.

Proposed Solution

  1. Preserve _cachedSpan during active typing while background isolate highlighting is in flight, rather than falling back to plain monochrome text.
  2. Provide a lightweight local line-level patch or keep the stale highlight span until the new isolate result arrives.
  3. Only update the active span once the worker isolate returns the new segments.

Acceptance Criteria

  • Typing in scripts >= 8 KB does not drop syntax highlighting or cause monochrome text flickering.
  • Syntax highlighting updates seamlessly once isolate worker returns updated spans.
  • Frame timing during typing remains within 60/120 Hz budget without jank.

Activity

  1. added
    editorCode/SQL editor
    performanceTheme parser epic label: performance
    coreCore library logic and services
    uiUser interface components and widgets
    P2Medium priority / Parity & Refactoring
    on Oct 10, 2026
  2. added a commit that references this issue on Oct 11, 2026
  3. ZhuchkaTriplesix commented on Oct 11, 2026

    @ZhuchkaTriplesix
    MemberAuthor

    Resolved in #1458 by introducing delta segment patching (patchHighlightSegments) during active typing in documents >= 8KB in QueryaHighlightController, preserving syntax colors without dropping to monochrome text while background isolate highlighting is in flight.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium priority / Parity & RefactoringcoreCore library logic and serviceseditorCode/SQL editorperformanceTheme parser epic label: performanceuiUser interface components and widgets

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions