Skip to content

fix(editor): prevent duplicate onChanged events, cursor false positives, and missing default highlighting in QueryaCodeEditor #1430

Closed

Description

@ZhuchkaTriplesix

Summary

In lib/core/editor/querya_code_editor.dart:

  1. Duplicate onChanged invocations:
    In build(), onChanged: widget.onChanged is passed to TextField. At the same time, _attachListener() binds _onTextChanged to _effectiveController, which also executes widget.onChanged?.call(_effectiveController.text). This causes onChanged to fire twice per keystroke.
  2. False positive onChanged on cursor moves / selection:
    _effectiveController.addListener(_onTextChanged) triggers on any change to TextEditingValue, including selection and cursor position. Without tracking _lastText, simply clicking or moving arrow keys invokes widget.onChanged.
  3. Missing syntax highlighting when controller == null:
    enableHighlighting is declared with doc When true and [language] is SQL/JSON, uses [syntax_highlight] if initialized, but _initControllerIfNeeded() always creates a plain material.TextEditingController() without highlighters. enableHighlighting is never read.
  4. didUpdateWidget ignores language/highlight changes:
    Only oldWidget.controller != widget.controller is checked. Toggling language does not reconfigure highlighters or controller.

Acceptance Criteria

  • onChanged is called exactly once per text modification, and never on cursor/selection changes.
  • When controller == null and enableHighlighting == true, QueryaCodeEditor creates a QueryaHighlightController via SyntaxHighlightService.
  • didUpdateWidget reacts to changes in widget.language and widget.enableHighlighting.
  • Unit tests cover duplicate prevention, cursor-movement safety, and default syntax highlighting.

Activity

  1. added
    bugSomething isn't working
    editorCode/SQL editor
    coreCore library logic and services
    P1High priority / Core capability
    on Oct 11, 2026
  2. added a commit that references this issue on Oct 11, 2026
  3. ZhuchkaTriplesix commented on Oct 11, 2026

    @ZhuchkaTriplesix
    MemberAuthor

    Fixed and verified in PR #1446.

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

    P1High priority / Core capabilitybugSomething isn't workingcoreCore library logic and serviceseditorCode/SQL editor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions