zuraffa_code_editor 7.6.1
zuraffa_code_editor: ^7.6.1 copied to clipboard
A customizable Flutter code field supporting syntax highlighting, code folding with visible closing lines, autocompletion and themes.
7.6.1 - 2026-11-20 #
7.6.1: pub.dev score improvements across the fleet — added a pana-recognized example/README.md to 12 packages (zuraffa_observability, session, storage, graphql, minio, tui, ffi, vendure, flutter, inappwebview, ocr, purchase); cleared all analyzer infos in zuraffa and zuraffa_flutter (deprecated flutter/material.dart -> material_ui, withOpacity -> withValues) for 50/50 static analysis.
7.6.0 - 2026-11-19 #
Fleet release 7.6.0: zuraffa_observability moves its OTel base to dartastic_opentelemetry with a sealed test-capture seam + facade re-exports (issue #4); zuraffa_vendure + zuraffa_graphql adopt graphql_plus ^5.3.0; fleet-wide zorphy/zorphy_annotation raised to ^2.5.1 with all entities regenerated from scratch.
7.5.0 - 2026-11-15 #
Release 7.5.0: Signal-backed view-state migration template with SignalScope ownership (#2076); signal listener/subscription cleanup on eager-delivery throw (#2081, #2083); UseCase/StreamUseCase catch-all SEVERE logs now carry the cause (#2077, #2079); dependencies upgraded and pinned to latest resolvable.
7.4.2 - 2026-11-13 #
- Mono-version fleet alignment to 7.4.2; internal dependencies refreshed; xml override 7.1.0.
7.4.1 - 2026-11-11 #
Fleet release 7.4.1: core adds zfa tunnel (Cloudflare-hosted MCP servers), MCP streamable-HTTP transport with usecase tools, blocking lifecycle hooks (#2032), typed tool param coercion (#2061); whole fleet mono-aligned to 7.4.1.
7.3.6 - 2026-11-02 #
- Mono-version fleet alignment to 7.3.6; internal dependencies refreshed; xml override 7.1.0.
7.3.2 - 2026-10-31 #
Mono-version fleet alignment to 7.3.2: outbound send port lands in zuraffa_intents (shareText/shareFiles behind ShareIntentService); the whole family ships at one version.
7.3.0 - 2026-10-28 #
- Mono-version fleet alignment: the whole zuraffa family ships at 7.3.0 together with the core.
zuraffadependency constraints unified to ^7.3.0; cross-family constraints move with the release.- Fleet-wide
dependency_overrides: xml: 7.1.0; README install guides refreshed to 7.3.0.
7.2.0 - 2026-10-28 #
- Mono-version fleet alignment: the whole zuraffa family now ships at the same version as the core.
zuraffadependency constraint unified to ^7.2.0 across the fleet.- zuraffa_storage now wraps the maintained
zuraffa_miniofork instead of the abandonedminiopackage (xml 7 compatible). - Fleet-wide
dependency_overrides: xml: 7.1.0policy; README install guides refreshed to the release version.
Changelog #
0.4.0 #
Changed #
- The code is drawn by
re_editornow, not by Flutter's text field. This is a breaking change: the rendering core moved fromTextField/EditableText— which lays the whole document out as one paragraph on every frame — tore_editor, which lays out only the lines that are on screen. A document of any length now costs the same to draw as a document of one screen.CodeFieldgained arendererparameter,CodeFieldRenderer, and the re_editor renderer is the default; the text field renderer is still there and is asked for withrenderer: CodeFieldRenderer.textField. Everything the package is for — the folding with its visible closing line, the named sections, the hidden ranges, the autocomplete, the search, the themes, the gutter — is unchanged, and the fold model, the history and the document all stay inCodeController: the re_editor side only ever sees the visible text, and the edits it reports are mapped back onto the full text. The migration plan is indoc/migrating/re_editor_migration_plan.md. - The package's own keyboard semantics are the ones that run. The re_editor renderer overrides the actions of the intents re_editor raises — the tab key, the enter key, the undo keys, the comment key and the find key — with the package's own, so the folds, the history and the modifiers stay in the controller's hands while the key bindings stay re_editor's. On Android and iOS re_editor handles the enter key itself, in the editor's own focus node, before any shortcut of the package's can: the enter key breaks the line there, instead of committing the suggestion or moving to the next search match.
- The package's own syntax highlight is off by default.
CodeControllergainedhighlightEnabled, and the parse it guards is quadratic in the document's length:package:highlight0.7.0 merges the text of a whole unmatched stretch into one node and copies the string merged so far on every merge, so a document whose top-level terminator matches rarely — which is what real code looks like — costs O(n²) to parse. It was parsed on every text change, and nothing needed it: the re_editor renderer highlights the code itself, withre_highlight, in an isolate. Measured on a fifty thousand line document: the controller's construction went from 47 000 ms to 743 ms, and a one-character edit from 58 725 ms to 1 223 ms. The text field renderer turns the flag on while it is mounted, because it draws the code with the highlighted spans, and the folding and the service comments are found in the raw text when there is no highlight to read them from.
Added #
CodeFieldRenderer: the renderer a code field draws the code with —CodeFieldRenderer.reEditor(the default) orCodeFieldRenderer.textField.CodeField.autofocus: whether the field takes the focus when it is mounted. Off by default, like before: only the re_editor renderer can honour it, and the text field renderer never focuses itself.CodeController.isDisposed: whetherdisposehas already run. A widget that changes the controller's settings after the frame it scheduled them in must check it: the controller may have been disposed in between.CodeController.setHighlightEnabledSilently: turns the package's own highlight on or off without notifying the listeners. A field that changes the flag while the framework is building uses this — the build that follows reads the new code, so there is nothing to notify, and a notification would arrive while the framework is building, which it refuses.CodeController.copySelection()andCodeController.cutSelection(): copy the selection to the clipboard, and cut it, the way the package's own copy shortcut does: the lines a fold hides are copied with the selection, because the selection is recovered over the hidden ranges first. What lands on the clipboard is what the document holds, not what is on the screen.
Fixed #
- The autocomplete popup is positioned again after the controller is swapped. The field listened to the popup controller of the controller it was given, and a host that hands the field a new one — a new document, a new language — left the listener on the old controller. The popup was then placed at an offset that was never computed.
- The copy and the cut take the hidden lines with them. On the desktop
platforms
re_editorbinds the copy and the cut keys itself, and it copies what is on the screen: the lines a fold hides were left out of the clipboard, and the cut removed only the visible part of the selection. The re_editor renderer overrides those two actions with the package's own now, so the clipboard holds the document, not the screen. - The gutter paints its rows without the line numbers. A gutter with
showLineNumbers: falseread the height of the number painter, which is never laid out when the numbers are hidden — the number column takes no width, so the painter is never measured — and the row height came back unlaid, which throws in debug. - The gutter's folding handle of a line past the document is gone, not a
crash. Asking for the handle of a line the document does not have indexed
the visible lines out of range and threw a
RangeError. It returns null now, like the handle of a line that is not on the screen. - The autocomplete popup has a border without a text style. The border's colour was read from the code style, which a host that gives the field no text style does not have, and the popup threw while it was built. It falls back to the ambient text colour.
0.3.6 #
Changed #
CodeController.buildTextSpanmemoises its span: a call whose inputs are unchanged returns the object the previous call returned, instead of walking and re-allocating the whole highlight tree (issue #114, upstreamakvelon/flutter-code-editor#127).EditableTextcallsbuildTextSpanon every rebuild — a selection move, a focus change, any parent rebuild — and each call re-ranSpanBuilderover the parsed tree and then flattened it again throughSearchResultHighlightedBuilder. The cache is keyed on everything the build reads: theCode, the style, the theme in scope, the language, the search result and the current search match, compared by the language's own structural equality. The navigation state itself is deliberately not keyed as an object: the search controller hands out a fresh instance on every change of the search result, and the rendered tree depends only on which match is current, so keying the object would invalidate on notifications that change nothing the tree shows. It holds one entry, it is replaced rather than grown, and it is invisible: no new field, no new public API, no way to turn it off or observe it. A hit returns the same object rather than a copy becauseRenderParagraphonly takes itsidenticalfast path for the object itself — a structurally equal copy still forces a relayout. The composing range is deliberately outside the cache, so the composing-aware path is never served a stale span.HiddenRangesasserts its merged invariant: the constructor now rejects a list in which any range touches the one before it (ranges[i].start == ranges[i - 1].end), not merely one that overlaps it (issue #118).HiddenRangesBuilderhas always merged touching ranges, so the assert fires only on a list constructed by hand — nothing inlib/builds one. With the invariant holding,recoverPositionno longer walks runs of adjacent ranges to honor the affinity: each collapse is a single range, and recovering it returns that range's own start or end. The class is internal and its observable behavior on lists that satisfy the invariant is unchanged.
Added #
- An ellipsis on a folded block's kept line: a line whose content a fold
hides now ends with
…, soparsers: [ ],reads as folded rather than merely short (issue #115, upstreamakvelon/flutter-code-editor#86). The gutter already hung a chevron on that row, but a row affordance says nothing to a reader looking at the text — or to a host that hides the gutter. The marker is painted, never typed:Code.visibleTextis the editing buffer, so an ellipsis inside it would shift the caret, every selection, the line numbering and the derived search offsets, and become selectable and typeable-over. It is spliced into the span treeSpanBuilderalready builds — after a closer the fold glued to the kept line, or after the opener when the closer took a row of its own — and paints at the line's own baseline through the sameTextPainter, at any wrapping. It carries the field's base style rather than the style of the token it follows, so an ellipsis after a string literal is not string-coloured, and one on a read-only line is not palled with the text around it. One marker per kept line: a block swallowed by an outer fold contributes none, because its kept line is hidden. Nothing is configurable — no glyph, colour or position — and no public API was added. The marker is suppressed while the search panel is slicing matches out of the tree, because match offsets are measured against the visible text and the marker's two characters would move every following match off its own text; it returns the moment the pattern is cleared. A caret parked on the folded line renders to the right of the marker rather than to its left — cosmetic, and the price of a marker that never enters the buffer.
Fixed #
-
The gutter no longer escapes the widget at a narrow field width: it now shares the row with the code area instead of laying out at its full
GutterStyle.widthwhatever the field had (issue #158, upstreamakvelon/flutter-code-editor#259). The gutter and the editor sit in aRow, and aRowsizes its non-flex children at their own request before handing the rest to its flex ones — so a field narrower than the gutter got a gutter wider than the field,A RenderFlex overflowed by N pixels, and aTextFieldlaid out out of sight beside numbers painted past the edge. The gutter is bounded to the row's width now — aLayoutBuilderwraps theRowand aConstrainedBox(maxWidth:)caps the gutter, so it takesstyle.widthwhile the row can give it and the row's whole width when it cannot. Every width the gutter derives still comes fromstyle.width, so a field wide enough to hold the gutter keeps it at the width it asks for — the gutter is 80 px by default and stays so from ~168 px of field width upward. -
A fold survives an edit to the newline that follows it (issue #160, upstream
akvelon/flutter-code-editor#175, reported as "hidden ranges of folded foldable block gets removed when you delete one of the consecutive new line chars after the block"). Deleting one of the blank lines under a folded block unfolded it: the fold marker went away and the hidden content rendered back in, which is the one outcome the reporter folded to avoid.FoldableBlockMatcher._editTouchedHiddenContenthad both bounds of the hidden-line span backwards — it exempted the block's own first line (firstLine + 1) and counted its closing row as hidden (.. lastLine).Code.foldableBlockToHiddenRangestarts the hidden range at the newline ending the first line and ends it at the start of the closing row so the closer stays on screen, so the span isfirstLine .. (closing ? lastLine - 1 : lastLine). An edit that replaces neither the first line's trailing newline nor any hidden line — one that removes the newline after the closer, or one of the blank lines under it — hides nothing this fold does, and the block keeps matching. The literal Backspace path never reproduced: the guard upstream added for#222refuses a collapsed single-character deletion that would remove a folded block, and it is keyed onoldSelection.isCollapsed— which is exactly why#175still reproduces through a selection edit, the shape the fix addresses.CodeLine.isClosingLinenow carries the closing-row test thatCodeused to hold inline, so the one definition serves both the hidden-range builder and the re-match. Pinned bytest/src/folding/fold_survives_newline_after_fold_test.dart(4 tests), atestWidgetsselection-delete case intest/src/code_field/code_controller_folding_editing_test.dart, and threeCodeLine.isClosingLineunit tests; the #108 identical-block and #222 backspace contracts stay green unchanged.
0.2.0 #
Added #
-
Current-line highlight:
CodeController.currentLineColor, a nullableColor?, tints the whole row of the line the caret is on — VSCode'seditor.renderLineHighlight: all(issue #113, upstreamakvelon/flutter-code-editor#194). The tint follows the caret through typing, tapping, arrow keys and a programmatic selection change, and the caret's character offset is converted to a line index by the editor, not by the host. It composes withlineBackgroundBuilder, which wins on the lines it colours whilecurrentLineColorfills in the rest, and left null — withlineBackgroundBuilderalso null — the field renders exactly as before: the layer is not in the tree at all. The doc example onlineBackgroundBuilderalso compared a line index against a character offset, which misattributed the tint to whichever line happened to contain that offset; it now points here. -
Customizable suggestion rows:
CodeField.suggestionItemBuilder, a nullableWidget Function(BuildContext, String suggestion, bool isSelected, VoidCallback onSelect)?, builds one row of the autocomplete popup, so a host can put an icon, a second line or its own selection affordance on a suggestion (issue #87, upstreamakvelon/flutter-code-editor#211). The builder is handed the suggestion's text — neitherPopupnorPopupControlleris exported from the package — whether that row is the selected one, and a callback that commits it exactly as the built-in row does, focus return included. The popup's own placement, flip and clamping stay the package's, because that is the part positioning tests pin. The builder's row is returned inside aMaterial(type: MaterialType.transparency)ancestor — the one thing the built-in row gives a host for free, and without which theListTilethis hook exists to enable has noMaterialancestor and asserts in debug. The row height stays out of the hook's reach: the popup measures each suggestion as the built-in single line and decides the flip and clamp on that, so a builder returning a taller row can overflow the space the flip reserved. Left null the popup renders the sameMaterial→InkWell→ColoredBox→Padding→Textrow as before. -
Per-line background colour:
CodeController.lineBackgroundBuilder, a nullableColor? Function(int lineIndex)?, tints the background of individual lines — the mechanism behind a current-line highlight, search-hit tints and error-line tints (issue #86, upstreamakvelon/flutter-code-editor#239). The builder is called once per rendered line with the line's 0-based index in the full, unfolded buffer — the same coordinate space asIssue.lineandFoldableBlock.firstLine— and returningnullleaves that line untinted. The tint covers the whole width of the line's row, including the stretch past its last character, and sits behind the editor's search-match highlighting, which still wins on a matched run. Lines inside a folded block or a hidden section are not rendered, so the builder is not asked about them, and the tint tracks the same per-row heights the gutter uses, so it lands on the right row through wraps and folds. Left null the field renders exactly as before: the layer is not in the tree at all. -
A multi-line Scala selective import folds as one imports block (issue #117, upstream
akvelon/flutter-code-editor#78).import users.{ User, UserPreferences }spread over several lines used to produce two foldable blocks — animportsblock that stopped at theimportline and a straybracesblock over the member list — so folding the import left the members on screen. A brace opened on an import line is now part of the import statement: it is absorbed instead of reported, and every line it spans counts as an import line, so the whole statement folds once. Go's parenthesized import group (import ( ... )) keeps folding as its own block, and a member list holding its own pairs (Map("k" -> "v")) produces no extra block. This also reachessetFoundPossibleImportand thepossibleImportbranch ofsubmitCurrentLine, previously dead code, so four line exemptions were removed from the coverage gate rather than renumbered. -
Batch folding API (issue #116, upstream
akvelon/flutter-code-editor#106).CodeControllerfolds blocks one at a time, so folding many meant a loop offoldAtcalls — each rebuilding theCode, assigningsuper.valueand notifying listeners, producing N intermediate states the user never sees (a 300-import file paid for 300 value assignments before settling).CodeController.foldBlocks( Iterable<FoldableBlock>)folds the given blocks in one pass: one newCode, one value assignment, one notification, regardless of count. Blocks that are already folded, or that the current code no longer holds, are skipped.foldImports()andfoldOutsideSections()now delegate to it and keep their exact behaviour; the upstream TODOs are removed.test/src/code_field/code_controller_fold_blocks_test.dartpins the loop-equivalent result, the single notification, the skips, and the selection-recovery parity. -
The gutter error popup is replaceable (issue #81, upstream
akvelon/flutter-code-editor#216). The ask named both a custom glyph perIssueType(delivered earlier this cycle asGutterStyle.errorIcon/warningIcon/infoIcon) and "provide my ownGutterErrorWidget" — the half that was still open. The gutter constructedGutterErrorWidgetitself with no injection point, so the popup's layout and behaviour were frozen for every consumer.GutterStylenow accepts a nullableerrorPopupBuilder, aWidget Function(Issue, TextStyle, BoxDecoration?)?that the gutter calls per issue with the already-resolved popup text style and decoration; leaving it null renders exactly theGutterErrorWidgetthe gutter has always constructed.test/src/gutter/gutter_error_widget_builder_test.dartpins both halves, the per-issue call, the null-text-style throw, and thecopyWithrelay. -
The Insert key toggles insert/overtype mode (issue #83, upstream
akvelon/flutter-code-editor#200, which points at the still-openflutter/flutter#122673). Flutter'sDefaultTextEditingShortcutsbinds only Ctrl-Insert (copy) and Shift-Insert (paste), so bare Insert falls through to the editor's own bindings and is now the overtype toggle. While overtype is on, a plain one-character keystroke at a collapsed caret replaces the character after the caret instead of inserting in front of it; the caret at the end of the text, a deletion, a paste, a multi-character selection, a keystroke a modifier transforms (auto-pairing) and a read-only field all keep inserting as before. The mode is a publicCodeController.isOvertypeMode, defaults to insert, and the key binding lives in_shortcutsIgnoredWhileComposingso a keystroke mid-IME-composition still belongs to the IME.test/src/code_field/insert_overtype_test.dartpins both halves, and Ctrl-Insert keeps copying. -
The cost of an unhighlighted editor is pinned by a test (issue #111 and issue #93, upstream
akvelon/flutter-code-editor#246).CodeControllercallshighlight.parseon every edit whether or not a language is configured, and both reports read that as the cause of a ~20 s stall on a 4800-line document with no language selected. Measured, it is not:highlight0.7.0 resolves an empty or unrecognised language name toplaintext— an empty mode with no keywords, no sub-modes and no auto-detection — so the highlight step costs 10–18 µs against 78.9–96.5 ms withjava, one keystroke medians 13–23 ms against 119.9–129.5 ms, and a paste of the whole document 16–23 ms against 124.8–129.2 ms. Neither path approaches the reported stall, and skipping the parse would remove at most ~18 µs from a ~14 ms keystroke, so no code changed.test/src/code_field/no_language_keystroke_test.dartpins the conclusion as ratios between the two paths plus absolute bounds of 100 ms per keystroke and 1 s per paste, and a fault injection that makes the no-language fallback resolve to a real language (parse 80 532 µs against the with-language 76 120 µs, keystroke 109 045 µs, paste ratio 0.98) reddens it — so a future change that makes an unhighlighted editor expensive fails the suite instead of reaching users.
Changed #
-
The gutter stays on the code line grid at any code font size (issue #107, upstream
akvelon/flutter-code-editor#312and#215). The gutter lays its rows out in aTable, whose row height is the tallest cell in it. The number is one code line tall, but the two fixed icon columns always rendered their glyph at 16px, so whenever the code's line box was shorter than 16 the icon set the row's height instead: the row pitch exceeded the code line height by the overshoot and the gutter separated from the code by that much again on every line below. The reported configurations never reach the case —height: 1.5atfontSize: 16and18gives a 24-27px line box, and so does thefontSize: 13, height: 1.6the existing grid pins use — which is why those pins pass while the drift is real. Measured on master atheight: 1.0, the pitch ran 10.500 against a 9px line box atfontSize: 9(10.5px of drift by the last row) and 13.643 against 13px atfontSize: 13(4.5px). Both icon glyphs are now clamped to the code line height, which is a no-op above a 16px line box, so every rendering that already fits is byte-identical — only the column widths were fixed before and only the glyph now shrinks.test/src/gutter/gutter_icon_row_height_test.dartpins the invariant across the whole sub-16 range, and all three fault-detecting tests are red without the fix (Expected <30.5> Actual <32.0>, the pitch of two stacked 16px glyph boxes). -
The code area's horizontal scroll is pinned on both of its paths (issue #85, upstream
akvelon/flutter-code-editor#280, reported as "horizontal scrolling does not work on iOS, works on Android"). Measured, the platform claim is the wrong way round: on a 240 px drag over the code text the code area scrolls 0 → 201 px under an iOS platform override and stays at 0 under an android one. The split is Flutter's, not this package's —TextFieldregisters aTapAndHorizontalDragGestureRecognizerwhoseeagerVictoryOnDragisdefaultTargetPlatform != TargetPlatform.iOS, and being deeper in the hit-test tree than the code area'sSingleChildScrollViewit enters the gesture arena first and, on non-Apple platforms, claims the drag for text selection. Nothing inlib/changed and no behaviour is new: the caret reveal already works on every platform and is pinned with it, and the drag split is now pinned so a Flutter upgrade that flipseagerVictoryOnDragfails the suite instead of silently changing who wins the drag. The correct follow-up — an interactive horizontalScrollbar, whose thumb drag uses its own recognizer deeper than theTextField's and so wins the same arena without touching selection — is recorded in.specify/bugs/ios-horizontal-scroll-85/assessment.md. -
A single tap commits an autocomplete suggestion, and the popup stays inside the window (issue #84, upstream
akvelon/flutter-code-editor#205). On mobile the suggestion popup needed a double tap and was cut off, becausePopup's row had the commit on itsonDoubleTap— so the gesture arena held the first tap back until the double tap timeout — and the popup was placed against the editor's render box while it actually renders in the full-screen overlay: the horizontal clamp subtracted an unexplained 100 px, which put the popup off the left edge of any editor narrower than 400 px, and the vertical flip was refused outright when the editor was shorter than the popup's maximum height. A tap now commits the word on its row exactly as Enter does, the popup is clamped into the window it is measured against — the real window, whichCodeFieldnow hands it instead of its own box — and the flip is decided by the height the suggestions actually need, capped at the popup's maximum height. -
A visible section renders flush with its contents (issue #35, upstream
akvelon/flutter-code-editor#109). A section whose[START name]and[END name]tags sit on lines of their own used to present a blank line before and after its contents — the shell of each tag line, the whitespace before the comment and the line break after it — and the gutter carried a number for both. Those two lines are now cut whole, so the presented section starts and ends with its own code. A tag that shares its line with code (class A {// [START s]) keeps its line, because the code before the comment belongs to the section; a section with no start tag cuts its end tag alone; and a document with no visible section is byte-for-byte unchanged.
Added #
-
The gutter's error icon is overridable, by issue type (issue #81, upstream
akvelon/flutter-code-editor#216). The gutter rendered one hardcoded redIcons.cancelfor every issue and offered no way to change it.GutterStylenow carrieserrorIcon,warningIconandinfoIcon— nullableIconDatas resolved per issue throughGutterStyle.issueIcon(IssueType)— andGutterErrorWidgettakes an optionaliconwidget for a host that mounts it directly. A style that sets none of them renders exactly the icon it always did: every type still falls back todefaultIssueIcon, which is the glyph theerrorIconconstant is now built from so the two cannot drift apart. Only the glyph is overridable — the icon is drawn at the issue column's own width, so its size stays part of the row geometry. -
The gutter error popup's decoration is overridable (issue #82, upstream
akvelon/flutter-code-editor#217). The popup's container chrome was derived inline from the popup text style'sbackgroundColorandcolor, which meant those twoTextStylefields were load-bearing for something that is not text styling and there was no way to set a shape or a border.GutterStyle.errorPopupDecorationnow supplies theBoxDecorationoutright, andGutterErrorWidget.popupDecorationdoes the same for a host that mounts the widget directly. Leaving it null keeps the existing derivation exactly, and the popup's content — message, url, suggestion and divider — is untouched either way. ApopupBuilderthat would replace the whole overlay is deliberately not in this change. -
Tab, Shift+Tab and Enter are dispatched through Flutter's
Shortcuts/Actionsmachinery, and the raw key path is now pinned as owning none of them (issue #29):CodeField'sFocusableActionDetectorsends Tab toTabKeyIntent, Shift+Tab toOutdentIntent, Enter toEnterKeyIntent, Ctrl+/ toCommentUncommentIntentand Ctrl+F toSearchIntent, andCodeController.actionsanswers each with its action;CodeController.onKeyhandles only Ctrl+F and the autocomplete popup's arrows and returnsignoredfor everything else. The negative is whattest/src/code_field/tab_through_shortcuts_test.dartpins — a regression that moved Tab back into a raw handler would leave every behavioural test green, because the observable effect of a Tab is identical either way. -
Outdent on Backspace, and a modifier hook that can carry it (issue #21): pressing Backspace inside a line's leading whitespace now removes one indent level instead of one space, and the modifier that does it is shipped in
CodeController.defaultCodeModifiers. Supplying your ownmodifierslist withoutOutdentModifierkeeps the plain one-character delete.This needed a new hook, because the one the reporter reached for cannot work: a
CodeModifieris keyed on the character that was typed, and a backspace removes a character rather than inserting one, so no key was ever produced and no modifier — on any character — could fire.CodeModifiernow takes an optionaldeletesChar, andCodeControllerkeeps a second map for those modifiers, keyed on the character that was removed. The dispatch is guarded by a single-character collapsed deletion, and a backspace over real code is still a one-character delete: the modifier declines any line whose leading run is not all spaces. A deletion cannot cross a read-only range or a folded block either — the modifier's result is folded into the value before those guards run. -
Web is a genuinely supported platform (issue #23):
autotrie, the one dependency in the graph that reported noplatform:web, is replaced by an in-house engine atlib/src/autocomplete/auto_complete.dart.autotrie's only entry point re-exportssrc/autotrie_base.dart, whose first line isimport 'dart:io', anddart:iohas no web implementation — that single import is why pub.dev listedandroid, ios, linux, macos, windowsand notweb, and why a web build of anything reaching the autocompleter failed to compile. The two methods that need it,AutoComplete.fromFileandAutoComplete.persist, are file-persistence helpers with no caller in this package, so the port carries the in-memory surface only andhiveleaves the graph withautotrie. Pinned bytest/src/autocomplete/auto_complete_test.dart(36 tests); the port corrects twoautotriedefects that cannot be fixed upstream, both unreachable fromAutocompleter:containsnow reports entered words rather than surviving prefix paths, anddeletenow clears the hit of the word it removes instead of leaving it suggested when a longer word shares its prefix.pubspec.yamlnow declares all six platforms explicitly, so the support cannot silently regress when a dependency that reachesdart:iois added. -
Right-to-left text direction support (issue #14):
CodeFieldgained atextDirectionparameter. Left null it resolves the ambientDirectionality, so an Arabic locale already renders right to left with no configuration — text, caret movement, the gutter (which flips to the right edge with the text) and the platform's bidi reordering of mixed Latin/Arabic runs. Set it to force a direction for a right-to-left snippet inside a left-to-right app.The defect this fixes was in the measurement, not the rendering: every
TextPainterthe field builds hardcodedTextDirection.ltr, so in an RTL field the autocomplete popup was positioned where the caret would be if the text ran left to right — the far side of the editor. The resolved direction now reaches theTextFieldand the caret painter that positions the popup. The row-height painters stayltrdeliberately: a paragraph's direction moves text horizontally, never vertically. Pinned bytest/src/code_field/text_direction_test.dart. -
HTML is reachable and documented as a first-class language (issue #40):
highlightships nohtmlmode — HTML is one of the aliases of itsxmlmode, and that mode already classifies the doctype, element names, attributes, attribute values, comments and entity references of a real document. The README's Languages › Syntax Highlighting section now says so instead of leaving the reader to conclude from a missingpackage:highlight/languages/html.dartthat HTML is unsupported, and the demo's language picker gainedhtmlandxmlentries so the path is demonstrable. Pinned bytest/src/highlight/html_language_test.dart. In practice,<script>and<style>bodies stay markup rather than being re-parsed as JavaScript or CSS inhighlight0.7.0: the mode does declaresubLanguageentries for both, but their<script/<styletag modes never match, so those entries never engage (<?php ?>bodies are parsed, as PHP). If a futurehighlightrelease fixes the matching, the bodies would start being re-parsed. -
tool/coverage_gate.pygained a line-level exemption mechanism.EXEMPT_LINESremoves individual unreachable lines from both the numerator and the denominator of the file they sit in — the same contractEXEMPT_FILEShas always had for whole files — and a stale-entry check warns when a listed line no longer matches anything inlcov.info. Every entry carries its proof in the comment above it, and the list is meant to stay short: if an exempted line becomes reachable, the test that reaches it is added and the entry dropped. -
22 new test files closing the reachable coverage gaps left over from the previous rounds: the autocompleter's blacklist and unknown-keyword paths, all six
Actiondelegates of the code field, the tab modifier,TextSelectionextension, named sections,AbstractAnalyzer.dispose, the single-line comment parser,KeyEventExtension, the fallback foldable block parser and the parser factory, the gutter fold toggles, the hidden range sort tie-break,SearchNavigationState.copyWith, the search bar's close icon, the CRLF row measurement of a wrapped field, and — new in this round — the gestural surface of the completion popup (a tap moves the selection and returns focus, a double tap commits the word) plus the recomputation of the search navigation index after a mid-search edit. -
A committed keystroke-latency benchmark.
test/src/code_field/edit_latency_test.dartmeasures the median keystroke at 200, 1000 and 3000 lines, prints the per-line latency, and fails on a super-linear regression, so the next report of "sluggish past a few hundred rows" starts from numbers instead of a sentence. -
CodeFieldexposescontextMenuBuilder(issue #12): an app can now replace the selection toolbar with its own actions (search, format, go to line) by passing anEditableTextContextMenuBuilder. When no builder is given, the field forwardsTextField's own default instead of an explicitnull, so the platform menu — Copy, Select All — survives unchanged for every existingCodeField.
Fixed #
-
A deleted folded block no longer folds its surviving identical twin (issue #108, upstream
akvelon/flutter-code-editor#83). Folding one of two textually identical blocks and then deleting the folded one folded the survivor:FoldableBlockMatcherdecides a fold survived an edit by comparing the fold's hidden content lines, and identical blocks have identical content, so the deleted block's fold re-attached itself to the twin. The edit's changed old-line range now travels with the re-match, and a fold whose first hidden line overlaps it is dropped with the block that was edited away — while the block's own first line stays exempt, so editing the visible line still keeps the fold. Pinned bytest/src/folding/fold_survives_identical_blocks_test.dart(4 tests) and the flipped upstream-recorded scenario intest/src/code_field/code_controller_folding_editing_test.dart. -
A
#no longer costs a Java file its highlighting (issue #104, upstreamakvelon/flutter-code-editor#42).highlight0.7.0'sjavamode declaresillegal: "<\\/|#", and_parsetreats an illegal lexeme as a silent bail — it throws, catches the throw itself and hands back the entire document as one unclassified node, so a single#outside a comment or a string literal (or a stray</) erased every class in the file. A triple-quoted string literal reached the same end by another route: with no triple-quote mode, the third"of"""opens an ordinary string whose content crosses a newline, and an ordinaryjavastring declares a newline illegal.CodeControllernow registers a repaired copy of thejavamode with the highlighter — theillegalregex dropped, a"""…"""string mode listed ahead of the single-quoted ones. It has to be a copy rather than the shipped mode with a field cleared, becauseModecaches the regexes compiled fromillegalandcontainson the first parse, so a cleared field leaves the stale regexes in place and the defect alive. Only the highlight parse sees the copy:controller.languageis still the mode the caller supplied, and every other language is registered exactly as it was given. Measured on master, bothpublic class A {\n}\n#\nandString s = """\nmultiline\n""";came back asResult(relevance: 0, nodes: [one node]); after the repair the first classifiespublic,class,titleand the second classifies the literal as onestringrun spanning all three lines. A raw newline inside an ordinary"..."still bails — a Java syntax error rather than a defect, and the other side of that trade has no clear winner — whiletest/src/highlight/java_language_test.dartpins the repaired classification and the unchanged one side by side. -
Folding and unfolding no longer throw away the selection they cover (issue #106, upstream
akvelon/flutter-code-editor#189, reported as "Fold-unfold deselects text"). A selection lives in the visible text, so the part of a selection that a folded block hides can only be shown truncated, clamped to the fold marker — which is whatCodeController.foldAt/unfoldAtdid, via_getValueWithCodelifting the selection into the full text and projecting it straight back. The lifted selection was discarded, so unfolding had nothing to restore from and recovered the truncated one: selectingreturn;and its brace and folding that block left the selection at[42, 45]instead of the original[43, 58], and it never came back._getValueWithCodenow keeps the lifted selection when cutting it through the new ranges and lifting it back does not return it — an exact predicate for "the fold truncated the selection" — and drops it the moment anything else re-establishes the selection: a change from the field,applyHistoryRecord(whose record carries a selection of its own), a whole-document replacement throughfullText, or a line-modifying edit, whose directsuper.valuewrite bypasses the setter. The report's own claim that a selection untouched by the fold is dropped does not reproduce — a drag selection overvoid method2()withvoid method1()folded tracks[58, 97]→[45, 84]and unfolds back to[58, 97], and that behaviour is pinned as well so the fix cannot resurrect a selection the fold never hid.test/src/code_field/fold_unfold_keeps_selection_test.dartpins the round trip for a covered selection, a covered caret, a straddling one, an untouched one, a selection the user moves while the block is folded, an unrelated unfold, a keystroke after the round trip, and the two bypass paths — afullTextreplacement and an indent while the block is folded, each red without the clear beside it. -
XML documents are foldable again (issue #103, upstream
akvelon/flutter-code-editor#311, reported as "HTML/XML highlighting is broken"). The highlighting half of the report does not reproduce:highlight.parse(src, language: 'xml')classifies a document intometa,commentandtagnodes carryingname,attrandstring, and drivingSpanBuilderwithvsThemeover those nodes paints them in six distinct colours, so the widget path is the same path and cannot differ. What does reproduce is the other half, "the document structure is lost":CodeController(text: ..., language: xml).code.foldableBlocksis empty, where java yields two brace blocks onclass A { void m() { } }.FoldableBlockParserFactoryspecial-cased python, java and yaml and sent everything else toHighlightFoldableBlockParser, which opens blocks on(,[and{only — and markup nests on<tag>/</tag>, so no bracket ever appears and no block is ever opened. Markup now has its own parser, driven by the highlight nodes rather than a text scan so a<inside a comment or an attribute string can never look like an element: nested elements produce nestedFoldableBlockType.markupblocks, self-closing tags (<br/>,<img src="x" />) and the<?xml ?>declaration produce none, a<a>text</a>pair on one line produces none becauseendBlockalready drops same-line blocks, and an unclosed element or a stray closing tag is reported as anInvalidFoldableBlockthe way an unclosed brace is. The Android layout intest/src/folding/parsers/markup_parser_test.dartnow folds itsLinearLayoutandFrameLayoutinstead of neither. -
Deleting a folded block's closer no longer destroys the block's content (issue #98, upstream
akvelon/flutter-code-editor#176). Backspacing the}of a folded block — the first visible character after the block's hidden range — recovered the replaced range with downstream affinity, which expanded the range into the hidden content and spliced it out of the document along with the brace. An edit that begins where a folded block's hidden range collapses now recovers its start after the content, so only the removed characters are deleted: the brace goes, the body survives, and the block releases because there is no closer left to fold. The guard is keyed on what the edit removes, not on the direction the visible text's length moved, so replacing the closer with longer text (typing} else {over it) is protected too — a pure insertion at that point keeps the documented downstream recovery. Edits at any other hidden range — a named section's marker comment — are unchanged. -
Folding a two-line block no longer deletes the line that starts the next one (issue #99, upstream
akvelon/flutter-code-editor#213). When a block's closing line was also the opening line of the next block and only one content line separated them (if (a &&/b) {), the guard that gives the closer a row of its own had nothing to work with and the fold hid the shared line whole — taking the following block's first line, its line number and its fold toggle off the screen. The range now ends at the shared line's start instead, gluing it onto the opener's row: the same shape a leading closer (}void main(){) already folds to, and the most a two-line fold can offer, since aHiddenRangecannot be empty. Multi-line touching blocks keep their closer's own row, and a leading-closer two-line shape folds exactly as before. -
dart analyzewarnings in the new tests — unused imports removed. -
A keystroke no longer rebuilds the visible highlight or re-indexes the whole document (issue #39, upstream
akvelon/flutter-code-editor#255).Code.foldedAscut and re-split the entire highlight tree a second time per keystroke even when it folded nothing,HiddenRanges.cutHighlightedrebuilt a structurally identical copy of that tree whenever nothing was hidden, andAutocompleter.setTextre-entered every word of the document into the autotrie. Each now does only the work the edit requires. Median keystroke on a 3000-line document measured 88.7 ms before and 77.9 ms after (−12%; −34% at 200 lines). Growth stays linear in rows — the remaining ceiling ishighlight.parseof the whole document, which has no incremental API here and is left to issue #22.
Changed #
-
The keystroke cost is measured, decomposed and pinned against super-linear growth (issue #22, upstream
akvelon/flutter-code-editor#264). One single-character keystroke in a 3000-line document costs ~84 ms underflutter test, and it ishighlight.parseof the whole document (~62%, 52–59 ms), theCode(...)construction (~18%, 15–18 ms),Autocompleter.setText(~7%, 5.6–6.7 ms) and the edit diff, tab replacement and selection mapping (~13%). Each of the three big terms is whole-document work, and none can be trimmed without an architectural change: thehighlightpackage lexes from offset 0 on every call with no incremental API,Codeis immutable and rebuilt wholesale, and the autocompleter's remaining_splitWordsscans the full text. The issue asks for lazy loading; upstream declined it for the same reason ("you would have to mostly rewrite the entire text editor"), and the measurement here confirms it, so the deliverable is the number and a guard, not a rewrite. The guard istest/src/code_field/edit_latency_test.dart: the per-line keystroke cost at 3000 lines within 2× the per-line cost at 200 lines, tightened from 3× after measuring the unmodified ratio at 1.01–1.25 over five runs. An injected O(rows²) pass inCodeLinesBuilder.textToCodeLines(+29 µs/line at 3000 lines) reddens it at 2.13×; reverting either of #39's O(n) trims does not, which is the honest limit of a linearity bound and is recorded in the spec. -
The coverage gate ratchets to 100%. The measured value is
100.00% (3089/3089 lines over 102 files); 13 lines are exempted individually as provably unreachable (dead branches, defensive guards, theItemScrollControllerassignment inPopupthat can never observe an attached controller, and the fold-toggle lambda that the second loop ofGutter._fillFoldTogglesalways overwrites).--min 97.7becomes--min 100in.github/workflows/dart.yaml. -
Generated artifacts are no longer versioned.
coverage/lcov.infoand theexample/ios/Flutter/ephemeral/output offlutter pub getare untracked and added to.gitignore, so a local coverage run or a plugin re-resolution cannot show up as a source change.
0.1.2 #
Fixed #
-
Foldable blocks that merely touch are no longer merged.
joinIntersectingjoined two blocks when the second began on the first block's last line, so}void main(){— the closer of one block and the opener of the next — became a single block and folding the first folded the second (issue #25). Touching blocks now stay separate (0..1,2..8,3..5,8..11). -
The block below keeps its start on screen. When a block's closing line also opens the following foldable block, the hidden range ends one character earlier so the closer keeps a row of its own — and with it the line number and the fold toggle the next block hangs there. The guard no longer requires the closer to be the line's first token, so a multi-line condition (
if (a &&/b &&/c) {) is covered too. The upstream glue default (parsers: [ ],) is unchanged.
0.1.1 #
Fixed #
-
Fold ranges now end at the start of the last line only when that line is a closing line (
),],}…). 0.1.0 applied this unconditionally, which hid only the newline before a non-closing last line and glued the neighbouring lines together: folding// first line // second line // third lineproduced
// first line// third line. Content lines — the tail of a//comment block, a continued argument, an import group — are hidden whole again, exactly as upstream does, while folded closers stay on screen as before:parsers: [ ],,void method() { },ScraperConfig();. -
The gutter now uses the code style's line height.
CodeField._buildGutter()copiedfontSizeandfontFamilyfrom the code style "for consistency with lines" but notheight, so gutter rows fell back to the font's own metrics — 19 px against the code's 21 px at the default style. The two grids therefore drifted ~1.9 px on every line, reaching ~60 px by line 36 of a typical file. Because the fold chevron is centred in its gutter row it inherited that drift, so chevrons climbed above the line they labelled (over half a line off by line 9, worse further down). The gutter now starts on the code text's top edge with a row pitch equal to the rendered line height.
Added #
gutter_alignment_test.dartpins the gutter/code grid invariant — top edge and row pitch — in both the folded and unfolded states.- Comment-block regression tests pinning that non-closing blocks hide their last line whole, with no glued text.
0.1.0 #
First release of zuraffa_code_editor, a maintained fork of
flutter_code_editor 0.3.5.
Changed #
- Folded blocks keep their closing line visible. Upstream hid a folded
block through the end of its last line, so folding
parsers: [ ... ]left a danglingparsers: [with no matching],— broken-looking code. The fold range now ends at the start of the block's last line, so the closing line stays on screen:parsers: [ ],,void method() { },ScraperConfig();. Gutter line numbering, fold-toggle placement and the number of rendered rows are all unchanged — only the closing text is added back. - Repackaged from
flutter_code_editortozuraffa_code_editor; all imports are nowpackage:zuraffa_code_editor/zuraffa_code_editor.dart. - Linting moved from
total_lintstoflutter_lints.
Thanks #
Everything except the fold change above is the work of the upstream akvelon/flutter-code-editor contributors. Changes to this fork's own code are dedicated to the public domain under CC0.
0.3.5 #
- Fixed line numbers not aligning with lines (https://github.com/akvelon/flutter-code-editor/pull/307)
0.3.4 #
- Added default height to
defaultTextStyle(https://github.com/akvelon/flutter-code-editor/pull/297). - Added
disposedandmountedchecks toCodeFieldandCodeController(https://github.com/akvelon/flutter-code-editor/pull/298). - Added
UndoHistoryControllertoCodeField(https://github.com/akvelon/flutter-code-editor/pull/302). - Added support for
yamlcomments (https://github.com/akvelon/flutter-code-editor/pull/305).
0.3.3 #
- Added
smartDashesTypeandsmartQuotesTypetoCodeField(https://github.com/akvelon/flutter-code-editor/pull/278). - Added named sections support for JavaScript and TypeScript (https://github.com/akvelon/flutter-code-editor/pull/291).
0.3.2 #
- Flutter 3.22 WASM fixes
0.3.1 #
- Support for Flutter v3.13.6.
0.3.0 #
- BREAKING: Deleted
CodeController.stringMap. - BREAKING: Deleted
themefromCodeController, (Issue 172).
0.2.24 #
- Hide the suggestion box when
CodeFieldis disposed (Issue 241). - Fix issues with Flutter 3.10.
0.2.23 #
- Added
CodeController.readOnly.
0.2.21 #
- 'Enter' key in the search pattern input scrolls to the next match.
0.2.20 #
- Alpha version of search.
0.2.17 #
0.2.16 #
0.2.10 #
0.2.9 #
- Hiding line numbers, errors, and folding handles (Issue 159).
- Indent new line after
:in Python (Issue 135). - Track the test coverage, add the codecov badge (Issue 146).
- Do not pale the editor if a visible section is set (Issue 153).
- Added GIFs to README (Issue 148).
- Fixed 'Index out of range' exception with visible sections on the default factorial example (Issue 152).
- Fixed linter issues (Issue 147).
0.2.4 #
- Exported
StringExtension. - Added an example with changing the language and the theme.
0.2.3 #
- Fixed removing listeners in
_CodeFieldState.dispose().
0.2.2 #
- Added
CodeController.lastTextSpanfield (visible for testing) to return the lastTextSpanproduced bybuildTextSpan().
0.2.1 #
- Added the migration guide for 0.2 to README.
0.2.0 #
- BREAKING: Removed theme from
CodeController. UseCodeThemewidget instead. - BREAKING: Removed
webSpaceFix, https://github.com/flutter/flutter/issues/77929 - BREAKING: Fixed typo
IntendModifier→IndentModifier. - BREAKING:
CodeFieldStateis now private.
0.1.15 #
- Added a missing code file.
0.1.13 #
- Remove an accidentally published temp file.
0.1.12 #
- Reformatted the license, updated README.
0.1.11 #
- Updated README.
0.1.10 #
- Fixed formatting.
0.1.8 #
- Fixed linter issues.
0.1.7 #
- Fixed README errors.
0.1.6 #
- Improved README.
0.1.5 #
- Updated license formatting to match pub.dev requirements.
0.1.4 #
- Added
CodeController.readOnlySectionNamesgetter and setter (Issue 110). - Added
CodeController.foldCommentAtLineZero,foldImports,foldOutsideSections(Issue 89). - Added
CodeController.visibleSectionNames(Issue 27). - Fixed folding Python blocks with multiline
ifconditions (Issue 108). - Fixed folding duplicate blocks like
[{...}]etc (Issue 99). - Fixed
cutLineIndexIfVisiblebug (Issue 112).
0.1.3 #
- Custom undo/redo implementation (Issue 97).
- Remove
FoldableBlockduplicates (Issue 99). - Copy folded text (Issue 24).
0.1.2 #
- Preserve selection when folding and unfolding (Issue 81).
0.1.1 #
- Added code folding.
- Fixed editing around hidden text ranges.
- Updated dependencies.
0.1.0 #
- Highlights unterminated blocks for Java and Python.
0.0.9 #
- Forked https://github.com/BertrandBev/code_field
- Re-license under the Apache license, mention the original author as the original license required.
- Added hidden service comment support.
- Added read-only blocks support.
- Added autocomplete for keywords, already-in-the-editor words, and external dictionary.