Skip to content

perf(editor): eliminate root TextSpan reallocation on cursor blink in QueryaHighlightController #1522

Open

Description

@ZhuchkaTriplesix

Summary

In lib/core/editor/querya_highlight_controller.dart (lines 70–75):

if (_cachedText == text &&
    _cachedBrightness == brightness &&
    _cachedSpan != null) {
  return TextSpan(style: style, children: [_cachedSpan!]);
}

Whenever the text cursor blinks in the editor (every 500 ms while idle), Flutter invokes buildTextSpan(). Even when neither the text, the style, nor the syntax highlighting spans have changed, a new wrapper TextSpan instance is allocated on every blink.

Proposed Solution

  1. Cache the root wrapper span:
    TextSpan? _cachedRootSpan;
    TextStyle? _cachedStyle;
  2. In buildTextSpan(), return _cachedRootSpan! if text == _cachedText, style == _cachedStyle, and brightness == _cachedBrightness.
  3. Invalidate _cachedRootSpan when text, style, or theme changes.

Acceptance Criteria

  • Cursor blinking in idle editor state produces zero heap allocations.
  • No regressions in text rendering or cursor movement.

Activity

  1. added
    editorCode/SQL editor
    performanceTheme parser epic label: performance
    coreCore library logic and services
    P3Low priority / Polish & Enhancements
    on Oct 12, 2026
  2. added this to the 0.5.0 milestone on Oct 12, 2026
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

    P3Low priority / Polish & EnhancementscoreCore library logic and serviceseditorCode/SQL editorperformanceTheme parser epic label: performance

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions