Repository navigation
feat: add editor essentials for CodeField - #3
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
just checkpasses (format, analyze, tests on the VM and JavaScript)CHANGELOG.mdhas an entry under## Unreleasedin each package changedBenchmarks
Not applicable.
Screenshots
Not applicable.