grammar: Fix parsing of expressions injected into strings

Fixes: #6014
This commit is contained in:
Tobias Hunger 2025-08-15 09:30:21 +00:00 committed by Tobias Hunger
parent fb9a2c0f47
commit 704779dfc7
2 changed files with 33 additions and 1 deletions

View file

@ -561,7 +561,17 @@
"patterns": [ "patterns": [
{ {
"name": "constant.character.escape.untitled.slint", "name": "constant.character.escape.untitled.slint",
"match": "\\\\(n|\\\\|u\\{\\d+\\}|\\{[^\\}]+\\})" "match": "\\\\(n|\\\\|u\\{\\d+\\})"
},
{
"name": "constant.character.escape.untitled.slint",
"begin": "\\\\\\{",
"end": "\\}",
"patterns": [
{
"include": "#expression"
}
]
} }
] ]
} }

View file

@ -0,0 +1,22 @@
// SYNTAX TEST "source.slint" "String parsing test based on #6014"
export component Test {
in property <bool> condition;
property <string> t1: "Text";
// ^^^^^^ string.quoted.double.slint
property <string> t2: "Text \{root.condition ? "\u{2003}" : ""}";
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double.slint
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.character.escape.untitled.slint
// ^^^^^^^^^^ string.quoted.double.slint
// ^^^^^^^^ constant.character.escape.untitled.slint
property <string> t3: "Test \{ root.condition ? "}" : ""} test";
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double.slint
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.character.escape.untitled.slint
// ^^^^ variable.language.special-element.slint
property <string> t4: "Test \{root.condition ? "{" : ""} foo ";
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ string.quoted.double.slint
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant.character.escape.untitled.slint
// ^^^^ variable.language.special-element.slint
}