Repository navigation
fix: colour code around inline annotations - #5112
Merged
Merged
Conversation
Preserve authored marks, line wrappers and link targets by cutting whole-source tokens at their text boundaries. Recolour only Leaf token nodes when a language changes, retaining equal spans. The prior no-colouring expectation for annotated blocks becomes coverage for colouring without removing annotations. Closes #5111
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.
Native code blocks now receive syntax colours through inline annotations without replacing the author's marks, line wrappers or link targets. The highlighter partitions whole-source tokens at the existing text boundaries and repaints only its own token nodes when the language changes, retaining equal nodes. This replaces the blanket refusal of authored elements that caused #5111.
Blocks containing
<br>stay uncoloured because their line breaks are absent fromtextContent. Content supplying its own colours uses the existing reading-face opt-out; this adds no new authoring option. The public helper's contract and feature gallery describe and demonstrate the behavior.The regression failed before the fix and passes afterward, including tokens cut across a mark, empty anchors, language changes and repeated highlighting. Five focused browser tests pass, covering language aliases, concurrent rewrites, personally themed content and comment anchoring.
pnpm run checkand pre-commit checks pass.The same annotated source on the base and candidate runtimes, in light and dark schemes:
Corpus startup comparison
leaf-dev probe corpus --basereached presentation on both runtimes, with 11 → 12 coloured native blocks and no recorded startup layout shifts. The document arrived before widgets upgraded and the first server state was presented. This is a single diagnostic comparison, not a timing benchmark.At presentation, code requests remain 142 (137 JavaScript); code bytes rise from 7,047,536 to 7,048,380, an increase of 844 bytes for preserving annotations during colouring. The new work belongs in the existing colouring pass so the block is coloured when the page is presented. Both arms report the quoted-playground initialization error tracked by #5072; this comparison does not establish a clean corpus render.
Reproduce the visual comparison with
uv run leaf-dev stills --state annotated-code --state annotated-code-dark --state native-code. The annotated source is identical in both arms; the existing JavaScript block's crops are identical.Closes #5111 — automated triage