Skip to content

perf(editor): eliminate full string equality comparison on cursor movement in QueryaCodeEditor #1542

Closed

Description

@ZhuchkaTriplesix

Problem

In QueryaCodeEditor._onTextChanged (lib/core/editor/querya_code_editor.dart), _effectiveController.addListener(_onTextChanged) is triggered on every cursor position change, arrow key navigation, and text selection update.
When currentText.length == _lastText.length, the method performs a full (N)$ string equality check currentText == _lastText across the entire document.
For 100KB-1MB SQL scripts, every arrow key press or selection shift runs a heavy string scan, causing typing and navigation latency.

Solution

  • Track TextEditingValue and verify whether text actually changed vs selection/cursor changes.
  • Avoid full-document string comparison when text identity or selection-only changes occur.

Benefits

  • 0 string scanning overhead during arrow key navigation and cursor selection in large documents.
  • Smooth, instant cursor movements in heavy SQL scripts.

Activity

  1. added
    performanceTheme parser epic label: performance
    enhancementNew feature or request
    editorCode/SQL editor
    coreCore library logic and services
    on Oct 12, 2026
  2. added this to the 0.5.0 milestone on Oct 12, 2026
  3. ZhuchkaTriplesix commented on Oct 17, 2026

    @ZhuchkaTriplesix
    MemberAuthor

    Closing: already handled. QueryaCodeEditor._onTextChanged starts with if (identical(currentText, _lastText)) return;. A caret move or selection change keeps the controller's text as the same String object (only selection changes in the new TextEditingValue), so it returns there without scanning the document. The full == runs only when the text object changed and has the same length, i.e. an actual edit that replaced characters, and then it stops at the first difference.

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 editorenhancementNew feature or requestperformanceTheme parser epic label: performance

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions