Skip to content

feat: add editor essentials for CodeField - #3

Merged
saminsohag merged 3 commits into
mainfrom
feature/editor-essentials
Oct 19, 2026
Merged

saminsohag merged 3 commits into
mainfrom
feature/editor-essentials

Conversation

@saminsohag

Copy link
Copy Markdown
Collaborator

Summary

Add editing syntax metadata and token queries for comments, strings and matching brackets. Build Flutter editor support for bracket and quote pairing, comment toggling, indentation, line numbers and selection decorations. Fix undo grouping so each CodeField edit takes one undo step, and relayout the gutter when a font finishes loading.

Related issue

None found.

Checklist

  • One change per pull request; unrelated fixes go in their own
  • just check passes (format, analyze, tests on the VM and JavaScript)
  • Tests added or updated — a fixed bug gets a regression test
  • Golden snapshots updated and reviewed, if highlighting changed
  • No breaking change, or it is called out below
  • CHANGELOG.md has an entry under ## Unreleased in each package changed
  • Docs updated if behaviour or API changed

Benchmarks

Not applicable.

Screenshots

Not applicable.

Engine (val_highlight):
- EditingSyntax: per-language comment markers, bracket pairs and quotes,
  declared on every built-in grammar and derived for custom ones.
- HighlightResult.matchingBracket, isStringOrCommentAt, isCommentAt and
  isInsideStringOrComment, answered from tokens so strings and comments
  never count as code.
- Markdown highlights <!-- --> comments.

Flutter (val_highlight_flutter):
- CodeEditing: auto-closing brackets and quotes with type-over and pair
  delete, selection wrapping, Enter splitting {|}, bracket matching.
- Typing handled as text changes via CodeEditingFormatter, so it works on
  on-screen keyboards and never touches IME composition.
- Toggle comment (Ctrl/Cmd+/) that treats doc comments and shebangs as
  content; Tab/Shift+Tab as overridable intents with rebindable shortcuts.
- Line-number gutter, highlighted and current line bands, painted from
  the editable's layout for visible lines only.
The text re-lays out when a late font arrives (common on the web), but the
gutter kept digits measured in the fallback font and did not repaint.
Listen to PaintingBinding.systemFonts, rebuild the digits and repaint.
Add CodeField.undoController (passed to the TextField) and tests that an
auto-closed pair, a split bracket pair, a wrapped selection, a toggled
comment and an indent each undo in one step, and that stepping over a
closer adds no step.
@saminsohag
saminsohag merged commit c76ebbb into main Oct 19, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant