Skip to content

Commit 1d4bc12

Browse files
committed
fix: Diagnostic for space separated scopes in capture
1 parent ab6cc50 commit 1d4bc12

13 files changed

Lines changed: 903 additions & 536 deletions

src/DiagnosticCollection.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,7 @@ function diagnosticsHints(diagnostics: Diagnostic[], document: vscode.TextDocume
11311131
(pattern . (patterns (key) @patterns . (_) .) .)
11321132
(repo (name (value) @name (#match? @name " ")) !name_scopeName)
11331133
(pattern (name (value) @name (#match? @name " ")) !name_scopeName)
1134+
(capture (name (value) @name (#match? @name " ")) !name_scopeName)
11341135
(contentName (value) @contentName (#match? @contentName " "))
11351136
`;
11361137
const captures = queryNode(rootNode, query);

syntaxes/json.tmLanguage.json

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,25 @@
847847
"end": "(?<=\")|(?=[},])",
848848
"beginCaptures": { "0": { "name": "punctuation.separator.dictionary.key-value.json.tm" } },
849849
"patterns": [
850+
{
851+
"comment": "\"...\"",
852+
"//": "TextMate 2.0 does not split scopes on spaces in their grammar files. But does so in their theme files.",
853+
"begin": "(\")(?=(?>[^\\\\\" ]++|\\\\[^ ])+ )(?=((?>[^\\\\\"]++|\\\\.)*)\")([^ ]+)(?=\\.)",
854+
"end": "(?<=\")",
855+
"beginCaptures": {
856+
"1": { "name": "$2 punctuation.definition.string.begin.json.tm" },
857+
"3": { "name": "$3" }
858+
},
859+
"contentName": "$2",
860+
"patterns": [
861+
{
862+
"match": "\"",
863+
"name": "punctuation.definition.string.end.json.tm"
864+
},
865+
{ "include": "#escape-characters" },
866+
{ "include": "#name_scopes" }
867+
]
868+
},
850869
{
851870
"comment": "\"...\"",
852871
"//": [
@@ -867,19 +886,6 @@
867886
"endCaptures": { "0": { "name": "punctuation.definition.string.end.json.tm" } },
868887
"name": "$1$2",
869888
"patterns": [
870-
{
871-
"comment": "TextMate 2.0 does not split scopes on spaces in their grammar files. But does so in their theme files.",
872-
"match": "\\G(?=(?>[^\\\\\" ]++|\\\\[^ ])+ )([^ ]+)(?=\\.)",
873-
"captures": {
874-
"1": {
875-
"name": "$1",
876-
"patterns": [
877-
{ "include": "#escape-characters" },
878-
{ "include": "#name_scopes" }
879-
]
880-
}
881-
}
882-
},
883889
{ "include": "#escape-characters" },
884890
{ "include": "#name_scopes" }
885891
]

syntaxes/tests/snaps/json.tmLanguage.json.snap

Lines changed: 267 additions & 151 deletions
Large diffs are not rendered by default.

syntaxes/tests/snaps/regex.tmLanguage.json.snap

Lines changed: 128 additions & 128 deletions
Large diffs are not rendered by default.

syntaxes/tests/snaps/searchResult.tmLanguage.json.snap

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
# ^ source.json.textmate punctuation.separator.dictionary.key-value.json.tm
119119
# ^ source.json.textmate
120120
# ^ source.json.textmate meta.resultBlock.search meta.embedded.json.textmate punctuation.definition.string.begin.json.tm
121-
# ^^^^^^^^^^^^^^^^ source.json.textmate meta.resultBlock.search meta.embedded.json.textmate meta.resultBlock
121+
# ^^^^^^^^^^^^^^^^ source.json.textmate meta.resultBlock
122122
# ^^^^^^^^ source.json.textmate meta.resultBlock.search meta.embedded.json.textmate
123123
# ^^^^^^^^^^^^^ source.json.textmate meta.resultBlock.search meta.embedded.json.textmate markup.italic
124124
# ^^^^^^^^^^^^^^ source.json.textmate meta.resultBlock.search meta.embedded.json.textmate
@@ -291,7 +291,7 @@
291291
# ^ source.json.textmate punctuation.separator.dictionary.key-value.json.tm
292292
# ^ source.json.textmate
293293
# ^ source.json.textmate meta.resultLine.search meta.resultLine.multiLine.search punctuation.definition.string.begin.json.tm
294-
# ^^^^^^^^^^^^^^^ source.json.textmate meta.resultLine.search meta.resultLine.multiLine.search meta.resultLine
294+
# ^^^^^^^^^^^^^^^ source.json.textmate meta.resultLine
295295
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.json.textmate meta.resultLine.search meta.resultLine.multiLine.search
296296
# ^ source.json.textmate meta.resultLine.search meta.resultLine.multiLine.search punctuation.definition.string.end.json.tm
297297
# ^ source.json.textmate punctuation.separator.dictionary.json.tm
@@ -381,7 +381,7 @@
381381
# ^ source.json.textmate punctuation.separator.dictionary.key-value.json.tm
382382
# ^ source.json.textmate
383383
# ^ source.json.textmate constant.numeric.integer meta.resultLinePrefix.search punctuation.definition.string.begin.json.tm
384-
# ^^^^^^^^^^^^^^^^ source.json.textmate constant.numeric.integer meta.resultLinePrefix.search constant.numeric
384+
# ^^^^^^^^^^^^^^^^ source.json.textmate constant.numeric
385385
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.json.textmate constant.numeric.integer meta.resultLinePrefix.search
386386
# ^ source.json.textmate constant.numeric.integer meta.resultLinePrefix.search punctuation.definition.string.end.json.tm
387387
# ^ source.json.textmate
@@ -453,7 +453,7 @@
453453
# ^ source.json.textmate punctuation.separator.dictionary.key-value.json.tm
454454
# ^ source.json.textmate
455455
# ^ source.json.textmate constant.numeric.integer meta.resultLinePrefix.search punctuation.definition.string.begin.json.tm
456-
# ^^^^^^^^^^^^^^^^ source.json.textmate constant.numeric.integer meta.resultLinePrefix.search constant.numeric
456+
# ^^^^^^^^^^^^^^^^ source.json.textmate constant.numeric
457457
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.json.textmate constant.numeric.integer meta.resultLinePrefix.search
458458
# ^ source.json.textmate constant.numeric.integer meta.resultLinePrefix.search punctuation.definition.string.end.json.tm
459459
# ^ source.json.textmate
@@ -645,7 +645,7 @@
645645
# ^ source.json.textmate punctuation.separator.dictionary.key-value.json.tm
646646
# ^ source.json.textmate
647647
# ^ source.json.textmate meta.resultLine.search meta.resultLine.singleLine.search punctuation.definition.string.begin.json.tm
648-
# ^^^^^^^^^^^^^^^ source.json.textmate meta.resultLine.search meta.resultLine.singleLine.search meta.resultLine
648+
# ^^^^^^^^^^^^^^^ source.json.textmate meta.resultLine
649649
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.json.textmate meta.resultLine.search meta.resultLine.singleLine.search
650650
# ^ source.json.textmate meta.resultLine.search meta.resultLine.singleLine.search punctuation.definition.string.end.json.tm
651651
# ^ source.json.textmate punctuation.separator.dictionary.json.tm
@@ -672,7 +672,7 @@
672672
# ^ source.json.textmate punctuation.separator.dictionary.key-value.json.tm
673673
# ^ source.json.textmate
674674
# ^ source.json.textmate constant.numeric.integer meta.resultLinePrefix.search punctuation.definition.string.begin.json.tm
675-
# ^^^^^^^^^^^^^^^^ source.json.textmate constant.numeric.integer meta.resultLinePrefix.search constant.numeric
675+
# ^^^^^^^^^^^^^^^^ source.json.textmate constant.numeric
676676
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.json.textmate constant.numeric.integer meta.resultLinePrefix.search
677677
# ^ source.json.textmate constant.numeric.integer meta.resultLinePrefix.search punctuation.definition.string.end.json.tm
678678
# ^ source.json.textmate

0 commit comments

Comments
 (0)