Skip to content

Commit 63956e5

Browse files
Merge #6248
6248: Textmate grammar: prevent early termination of raw strings with hash (closes #6042) r=matklad a=dustypomerleau Problematic sample code from #6042: ```rust #[derive(Debug, Clone, Logos)] enum Quoted<'source> { #[regex(r#"[^\\"']+"#)] Text(&'source str), #[token("\\")] StartEscape, #[token("\'", |_| Quote::Single)] #[token("\"", |_| Quote::Double)] End(Quote), #[error] Error, } ``` Before fix: <img width="400" alt="Screen Shot 2020-10-16 at 10 45 59" src="https://user-images.githubusercontent.com/6304651/96198390-6a726d00-0fa0-11eb-8428-e76b2866836b.png"> After fix: <img width="400" alt="Screen Shot 2020-10-16 at 10 45 33" src="https://user-images.githubusercontent.com/6304651/96198408-7a8a4c80-0fa0-11eb-9104-ca708009fe63.png"> Co-authored-by: Dusty Pomerleau <[email protected]>
2 parents 783c6a3 + c2335d0 commit 63956e5

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

editors/code/rust.tmGrammar.json

+22-3
Original file line numberDiff line numberDiff line change
@@ -966,9 +966,28 @@
966966
]
967967
},
968968
{
969-
"comment": "double-quoted raw strings and raw byte strings",
969+
"comment": "double-quoted raw strings and raw byte strings (no hash)",
970970
"name": "string.quoted.double.rust",
971-
"begin": "(b?r)(#*)(\")",
971+
"begin": "(b?r)(\")",
972+
"beginCaptures": {
973+
"1": {
974+
"name": "string.quoted.byte.raw.rust"
975+
},
976+
"2": {
977+
"name": "punctuation.definition.string.rust"
978+
}
979+
},
980+
"end": "\"",
981+
"endCaptures": {
982+
"0": {
983+
"name": "punctuation.definition.string.rust"
984+
}
985+
}
986+
},
987+
{
988+
"comment": "double-quoted raw strings and raw byte strings (with hash)",
989+
"name": "string.quoted.double.rust",
990+
"begin": "(b?r)(#+)(\")",
972991
"beginCaptures": {
973992
"1": {
974993
"name": "string.quoted.byte.raw.rust"
@@ -980,7 +999,7 @@
980999
"name": "punctuation.definition.string.rust"
9811000
}
9821001
},
983-
"end": "(\")(#*)",
1002+
"end": "(\")(#+)",
9841003
"endCaptures": {
9851004
"1": {
9861005
"name": "punctuation.definition.string.rust"

0 commit comments

Comments
 (0)