Skip to content

refactor(editor): decouple QueryaCodeEditor from highlight controller lifecycle and manage at session level #1366

Closed

Description

@ZhuchkaTriplesix

Summary

In lib/core/editor/querya_code_editor.dart (lines 62–185):
QueryaCodeEditor is currently burdened with multiple non-UI responsibilities:

  1. It maintains two distinct controllers simultaneously: an internal _highlightController and an external widget.controller (_plainController).
  2. It sets up two-way listeners (_syncFromExternal / _syncToExternal) that perform full-string equality comparisons on every single keystroke (perf(editor): eliminate two-way controller bouncing and full-string comparisons in QueryaCodeEditor #1352).
  3. It performs hash calculations on tokenColors and recreates controllers inside build() during theme transitions (perf(theme): cache tokenColorsHash on QueryaTheme to eliminate Object.hashAll in QueryaCodeEditor.build() #1353, perf(theme): eliminate continuous QueryaHighlightController recreation during AnimatedQueryaTheme transitions #1358).

This violates clean widget architecture by making the presentation editor responsible for highlight controller lifecycle and state synchronization.

Proposed Solution

  1. Transform QueryaCodeEditor into a clean presentation widget that accepts a single, already-configured TextEditingController (which can be a QueryaHighlightController or plain TextEditingController).
  2. Move highlight controller instantiation, grammar loading, and lifecycle management to SqlQueryTabSession (or a dedicated CodeEditorControllerFactory).
  3. Eliminate the two-way sync loop and full-string comparisons between controllers.

Acceptance Criteria

  • QueryaCodeEditor does not maintain dual synchronized controllers.
  • Text editing and syntax highlighting remain fully functional across all workspaces.
  • Keystroke overhead during typing is reduced.

Activity

  1. added
    editorCode/SQL editor
    frontendTheme parser epic label: frontend
    coreCore library logic and services
    P3Low priority / Polish & Enhancements
    on Oct 10, 2026
  2. ZhuchkaTriplesix commented on Oct 11, 2026

    @ZhuchkaTriplesix
    MemberAuthor

    Done in #1391 (merged into dev).

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 editorfrontendTheme parser epic label: frontend

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions