Repository navigation
Colour the file editor with Leaf's one tokenizer and theme - #6776
Merged
Merged
Conversation
The file editor coloured YAML with Lezer's YAML grammar, which tags every plain value as content, so numbers, booleans and null took the string colour where a YAML code block colours them apart, and it kept its own table of Lezer tags to Leaf's colours beside the token theme code blocks, diffs and lf-code use. Its Markdown wore a face of its own (accent bold headings) and every other language read as plain text. The editor now colours every language the registry's `$languages.paths` names through the syntax module code blocks use. CodeMirror's StreamLanguage drives Shiki's tokenizer a line at a time, from the grammar state the line before ended in, which `syntaxNow` (portable-api.js) gives as a synchronous call once the grammar has loaded. Each declaration a token's style can hold, a theme colour or a font style, is one tag, so a token's style comes from the one theme. The editor's colour table, its Lezer YAML module (39,619 bytes) and the core CodeMirror bundle's Lezer Markdown (36,544 bytes) go, with @codemirror/lang-yaml, @codemirror/lang-markdown and @lezer/markdown. Behaviour that changes: Markdown in the editor reads as a Markdown code block does (headings in the name colour, no bold or underline), so test_file_editor_uses_package_typography_and_the_inherited_focus_ring reads the heading's colour rather than its weight, and inline code as one token with its backticks. test_a_file_reads_in_the_colours_of_a_code_block_of_it holds a YAML number, boolean, null, key, string and comment and a Markdown heading to their faces in a code block of the same file; on main the number and boolean differ. The key check in test_a_file_tree_opens_each_file_the_editor_holds moves into it. Measured in a probe typing 40 keys mid-file (CodeMirror's update and measure per key): Chromium 1.7 ms at 2,000 lines and 2.9 ms at 7,400, where Lezer took 4.4 and 15.8; Firefox 3.8 and 4.7, where Lezer took 11.9 and 21.4. Enter after a YAML key, a YAML value, a bullet and a numbered item lands at the same column before and after: neither version indents past the line or continues a list marker.
leaf-agent
reviewed
Nov 22, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
The first "To weigh" item asks the maintainer to decide how Markdown should look in the editor, but the PR includes no picture of it. With this change, Markdown files lose their heading weight, bold, italic and link underline, and the file editor is mostly used for Markdown. Root AGENTS.md, "Working on the repository", asks that every UI option left to the user come with a picture of its result. Before/after stills of a Markdown file in the editor, plus the variant with the four shared-theme rules, would let the maintainer make that call from the PR.
…eystroke The tokenizer now runs inside CodeMirror's update, where Lezer could not throw: a grammar pattern the JavaScript regex engine cannot compile, or a partition check that fails, would escape dispatch and take the keystroke that reached the line, and every one after, with it. Such a line stays plain, and the failure is logged once for the render gate. Raised in review; no input that throws has been found.
# Conflicts: # tests/browser/test_render_files.py
…strong words, italic emphasis, underlined link addresses Three rules in Leaf's token theme (build/entries/syntax/entry.mjs) set a heading and `**strong**` words bold, `*emphasis*` italic and a link's address underlined. The file editor and code blocks read the same theme, so a Markdown file shows these faces in the editor and in a Markdown code block alike, and so does a diff of a Markdown file. Before this, the branch had dropped the editor's bold headings and bold strong words with Lezer's Markdown, and code blocks never had them. Of the bundled grammars only Markdown marks text with these scopes. Max picked this look over the plain one on the decision page in his session. The file-editor colour test now also checks the faces of a heading, a strong run, an emphasis run and a link's address, in the editor and in a code block, and fails without the rules.
max-sixty
marked this pull request as ready for review
November 23, 2026 04:24
Collaborator
leaf-agent
approved these changes
Nov 23, 2026
max-sixty
added a commit
that referenced
this pull request
Nov 23, 2026
Fixes a file editor leftover from #6019: on a phone, a wrapped YAML row started at the editor's edge, like a new key. **Wrapped rows hang from their line's indent.** Rows now start two columns past the indent, behind the ↪ mark code blocks use. That hang now has one rule, in `marks.css`, which the document, every shadow stage and now the composer adopt; code blocks, drafts and the editor mark their lines `data-lf-pre-line` and state only their padding. `lf-code` keeps its own, since its `::before` is the line number. The editor takes the look code blocks and the reply box already have, so a file wraps the same way in each. Max left the pick to me. The alternative was rows at the indent with no mark, as VS Code does: it would give the editor a look of its own, and at phone width a wrapped row then reads as a value under its key. To weigh: the core bundle exports CodeMirror's `countColumn`; the write watch allows CodeMirror's restated line `style`. Left out: the marks for a write that rewrites a line and removes the next ones stay as on `main`, on Max's pick; YAML number and boolean colours merged as #6776; a plain link to a pane no longer moves the page on `main`. Tests: a phone check of where wrapped rows start, and one runtime case for a rewrapped paragraph's marks; `pnpm run test:runtime`. > _This was written by Claude Code on behalf of max-sixty_
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.



The file editor now colours every language
$languagesnames with the tokenizer and theme code blocks use, so a YAML number, boolean or null reads as it does in a code block, where Lezer's YAML grammar coloured every plain value as a string. CodeMirror'sStreamLanguageruns Shiki a line at a time through a new synchronoussyntaxNow, and the editor's colour table, Lezer YAML and Lezer Markdown go.Three rules in the shared theme set Markdown headings and
**strong**words bold,*emphasis*italic and link addresses underlined, in the editor and code blocks.To weigh:
Tests: one compares the editor's colours and faces with a code block's, failing on
mainand without the rules;pnpm run check.