Skip to content

fix(editor): prevent duplicate onChanged, cursor false positives, and enable default highlighting (#1430) - #1446

Merged
ZhuchkaTriplesix merged 1 commit into
devfrom
issue/1430-code-editor-events-highlight
Oct 11, 2026
Merged

ZhuchkaTriplesix merged 1 commit into
devfrom
issue/1430-code-editor-events-highlight

Conversation

@ZhuchkaTriplesix

Copy link
Copy Markdown
Member

Closes #1430

Changes

  1. Prevent duplicate onChanged invocations:
    • Removed onChanged: widget.onChanged from inner Material and Shadcn TextFields to avoid firing twice per keystroke alongside _effectiveController listener.
  2. Prevent false positive onChanged on cursor / selection changes:
    • Added _lastText tracking in _QueryaCodeEditorState. _onTextChanged compares currentText == _lastText and skips firing when only selection/cursor changed.
  3. Enable default syntax highlighting:
    • When widget.controller == null and widget.enableHighlighting == true, initialize _internalController using SyntaxHighlightService.createHighlightController so SQL/JSON syntax highlighting works out of the box.
  4. React to language and highlighting changes in didUpdateWidget:
    • Reconfigures _internalController when language or enableHighlighting changes, preserving current text and selection.
  5. Unit tests:
    • Added widget tests in test/core/editor/querya_code_editor_test.dart validating:
      • exactly one onChanged call per typed character edit.
      • 0 onChanged calls on cursor clicks and selection changes.
      • creation of QueryaHighlightController by default when enableHighlighting is true.
      • creation of plain TextEditingController when enableHighlighting is false.
      • seamless update of highlight controller and preservation of text on language change.

@ZhuchkaTriplesix
ZhuchkaTriplesix merged commit adef5ea into dev Oct 11, 2026
11 checks passed
@ZhuchkaTriplesix
ZhuchkaTriplesix deleted the issue/1430-code-editor-events-highlight branch October 11, 2026 09:04
@github-actions github-actions Bot added bug Something isn't working editor Code/SQL editor core Core library logic and services P1 High priority / Core capability labels Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working core Core library logic and services editor Code/SQL editor P1 High priority / Core capability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant