Skip to content

Commit 547b019

Browse files
committed
Give YAML number/bool/null plain scalars a string-scalar ancestor
A typed plain scalar (`42`, `true`, `null`) is first an unquoted plain scalar — lexically a string — that the schema then resolves to a number / boolean / null. It was scoped as a flat `constant.numeric` / `constant.language`, missing the `string.unquoted` ancestor the official grammar carries (`string.unquoted.plain.out` › `constant.*`). That ancestor is load-bearing for folding: when a value scalar is continued by a more-indented line (`: null\n d`) the value is actually the multi-line plain string "null d", but a highlighter cannot see the continuation while scoping the first line. The `string.unquoted` ancestor keeps it string-typed regardless, while a standalone `null` still reads as the constant from the leaf — so both the folded (lit.string) and standalone (constant) roles grade correctly. Token scopes may now be space-separated; the generic token emit namespaces each part with langName independently (a no-op for the single-scope case, so the other grammars stay byte-identical). YAML scope-gap 99.66% -> 99.75% (lit.string 564->565, exact 99.5%), gap to official 0.3 pts. Refs #12
1 parent e811d62 commit 547b019

4 files changed

Lines changed: 630 additions & 19 deletions

File tree

src/gen-tm.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4570,7 +4570,10 @@ export function generateTmLanguage(grammar: CstGrammar, langName: string): TmGra
45704570
// (`variable`) → correctness is unchanged; only the path is finer.
45714571
const emittedScope = tok === identToken ? `${scope}.readwrite` : scope;
45724572
repository[key] = {
4573-
name: `${emittedScope}.${langName}`,
4573+
// A space-separated scope (e.g. `string.unquoted constant.language` for a YAML plain
4574+
// scalar that resolves to a constant) becomes a multi-scope TM name — each part namespaced
4575+
// with `langName` independently. No-op for the common single-scope case.
4576+
name: emittedScope.split(' ').map(s => `${s}.${langName}`).join(' '),
45744577
// The bare-identifier rule must scope non-ASCII names too (`Ω`, Cyrillic `А`).
45754578
match: tok === identToken ? identPattern : tokenPatternSource(tok),
45764579
};

0 commit comments

Comments
 (0)