Repository navigation
Highlight markup in exported components and control blocks - #86
Merged
Merged
Conversation
source.tsx read the body of an exported component, and the block of a Control form inside markup, as an export clause or an object literal, so their markup got no tag scopes (solidjs#85). #export-declaration matches `export` (and `default`, only before `component`) in front of a .rx declaration, so source.tsx never enters its export state. #control-block opens at a Control header (`{for x in E`, `{if E`, `} else`, `fallback (e)`) and tokenises each following block like a component body; a header opens it only when a `{` follows on its line. Fixes solidjs#85. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ryansolid
pushed a commit
that referenced
this pull request
Nov 20, 2026
solid-next.sh takes #87's version (fetch the pin by hash, SOLID_BRANCH); the pin stays 99db9bce4. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0117BoWLtkg281f1NkGEDjCt
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.
Fixes #85.
Markup in an exported component, and in a control block written inside markup, gets no tag scopes:
source.tsxreads the{ … }as an export clause or an object literal, so the tags come out as identifiers and comparison operators. #85 has the reproduction and the scopes.Change
Two rules in
tooling/vscode-rx/syntaxes/rx.tmLanguage.json; nothing existing is edited.#export-declaration, a root pattern, matchesexportbeforecomponent,fn,action,source,context,errorordeferredand a name, sosource.tsxnever enters its export state.defaultis matched only beforecomponent, the one default export the spec allows (Decl).export pure|server|clientand exported equations are left to the existing injections, which already handle them.#control-block, injected ahead of the existing patterns, opens at a header from the spec'sControlproduction ({for x in E,{if E,} else,fallback (e)) and treats each following{ … }as a statement block containing$self, the same context as a component body. It ends after the last block, sofallback { … } { … }and} else {stay inside it.{follows on its line, and the keywords use$-aware boundaries. So the same words in markup text (<p>loading fallback text</p>), anifwithout a block in an action, or anif:property can't leave a scope open.Evidence
Measured with Shiki 1.24.0 (the version
tooling/syntax-previewpins) on the Oniguruma engine. "Tag tokens" counts tokens whose innermost scope isentity.name.tag*.examples/Across all 432 files (12,363 lines), lines with a
<Tagthat isn't scoped as a tag, string or comment drop from 3,250 to 3.<comparisons, generic function types in object literals, comparisons continued on a line starting with<,export { a },export type,export interface,export const,export * from,export default <expression>, and indentedexport pure fn.npm run renderintooling/syntax-previewrenders every example with the new grammar.Known limits
None of these is a regression from the current grammar.
{" "}spacer in a statement block stays uncoloured (examples/ai2/search/ui.rx:62,examples/ai2/tracker/ui.rx:29and:32). That comes fromsource.tsx's own expression rules.fallback { … }with its second block on the next line: the second block isn't covered, because a TextMate end pattern can't look past the line. Nothing runs away.rxfences:L:source.rxinjections don't apply there, because embedding doesn't pushsource.rx. That's true of every existing injection, and this PR doesn't change it.fn name(…): Tsignature: its return-type state carries to the next non-exportline, as a non-exported signature's already does.exportand the declaration (export /* c */ component) keeps today's behaviour.Not run
The
ref/suite can't be affected by an editor grammar, so I didn't run it. The change doesn't touch the language server, and no version is bumped.Disclosure: this PR was created with the assistance of Fable 5.2 (Claude), which reviewed the change over two rounds; the grammar and this description were written with Claude Opus 5.5.
🤖 Generated with Claude Code