mirror of
https://github.com/godotengine/godot-vscode-plugin.git
synced 2025-12-31 13:48:24 +03:00
Various highlighting/formatting fixes (#559)
* Fix constant attribute access highlighting * Fix line endings breaking the snapshot tests * Fix nodepath shorthand formatting
This commit is contained in:
@@ -34,7 +34,7 @@ suite("GDScript Formatter Tests", () => {
|
||||
await vscode.workspace.applyEdit(workspaceEdit);
|
||||
|
||||
// Compare the result with the expected output
|
||||
expect(documentIn.getText()).to.equal(documentOut.getText());
|
||||
expect(documentIn.getText().replace("\r\n", "\n")).to.equal(documentOut.getText().replace("\r\n", "\n"));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -6,12 +6,15 @@
|
||||
|
||||
func f():
|
||||
print("$Sprite1", $Sprite1)
|
||||
print("%Sprite1", %Sprite1)
|
||||
print( "%Sprite1" , %Sprite1)
|
||||
var a=val % otherVal
|
||||
|
||||
@onready var score := $HBoxContainer/Score as Label
|
||||
|
||||
var a = $Child
|
||||
var a = $Child/ GrandChild
|
||||
var a = $Child/ GrandChild / GreatGrandChild
|
||||
var a = $Child/ Lots / Of / Grand / And / Great / Grand / Children . do_stuff()
|
||||
var a = $"../Sibling"
|
||||
var a = $'../Sibling'
|
||||
var a = $"../ Sibling "
|
||||
|
||||
@@ -9,9 +9,12 @@ func f():
|
||||
print("%Sprite1", %Sprite1)
|
||||
var a = val % otherVal
|
||||
|
||||
@onready var score := $HBoxContainer/Score as Label
|
||||
|
||||
var a = $Child
|
||||
var a = $Child/GrandChild
|
||||
var a = $Child/GrandChild/GreatGrandChild
|
||||
var a = $Child/Lots/Of/Grand/And/Great/Grand/Children.do_stuff()
|
||||
var a = $"../Sibling"
|
||||
var a = $'../Sibling'
|
||||
var a = $"../ Sibling "
|
||||
|
||||
@@ -90,7 +90,7 @@ function between(tokens: Token[], current: number) {
|
||||
if (!prev) return "";
|
||||
|
||||
if (next === "#") return " ";
|
||||
if (prevToken.skip) return "";
|
||||
if (prevToken.skip && nextToken.skip) return "";
|
||||
|
||||
if (nextToken.param) {
|
||||
if (next === "%") return " ";
|
||||
|
||||
@@ -321,7 +321,8 @@
|
||||
"builtin_get_node_shorthand": {
|
||||
"patterns": [
|
||||
{ "include": "#builtin_get_node_shorthand_quoted" },
|
||||
{ "include": "#builtin_get_node_shorthand_bare" }
|
||||
{ "include": "#builtin_get_node_shorthand_bare" },
|
||||
{ "include": "#builtin_get_node_shorthand_bare_multi" }
|
||||
]
|
||||
},
|
||||
"builtin_get_node_shorthand_quoted": {
|
||||
@@ -341,18 +342,28 @@
|
||||
},
|
||||
"builtin_get_node_shorthand_bare": {
|
||||
"name": "meta.literal.nodepath.gdscript",
|
||||
"begin": "(\\$|%|\\$%)([a-zA-Z_]\\w*/?)",
|
||||
"match": "(?<!/\\s*)(\\$|%|\\$%)([a-zA-Z_]\\w*)\\b(?!\\s*/)",
|
||||
"captures": {
|
||||
"1": { "name": "keyword.control.flow.gdscript" },
|
||||
"2": { "name": "constant.character.escape.gdscript" },
|
||||
"3": { "name": "constant.character.escape.gdscript" }
|
||||
}
|
||||
},
|
||||
"builtin_get_node_shorthand_bare_multi": {
|
||||
"name": "meta.literal.nodepath.gdscript",
|
||||
"begin": "(\\$|%|\\$%)([a-zA-Z_]\\w*)",
|
||||
"beginCaptures": {
|
||||
"1": { "name": "keyword.control.flow.gdscript" },
|
||||
"2": { "name": "constant.character.escape.gdscript" }
|
||||
},
|
||||
"end": "(?!%?\\s*[a-zA-Z_]\\w*)\\s*/?*",
|
||||
"end": "(?!\\s*/\\s*%?\\s*[a-zA-Z_]\\w*)",
|
||||
"patterns": [
|
||||
{
|
||||
"match": "(%)?\\s*([a-zA-Z_]\\w*)\\s*/?",
|
||||
"match": "(/)\\s*(%)?\\s*([a-zA-Z_]\\w*)\\s*",
|
||||
"captures": {
|
||||
"1": { "name": "keyword.control.flow.gdscript" },
|
||||
"2": { "name": "constant.character.escape.gdscript" }
|
||||
"1": { "name": "constant.character.escape.gdscript" },
|
||||
"2": { "name": "keyword.control.flow.gdscript" },
|
||||
"3": { "name": "constant.character.escape.gdscript" }
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -518,7 +529,7 @@
|
||||
"name": "variable.other.gdscript"
|
||||
},
|
||||
"any_property": {
|
||||
"match": "\\b(\\.)\\s*(?<![@\\$#%])(?:(\\b[A-Z_][A-Z_0-9]*\\b)|([A-Za-z_]\\w*))\\b(?![(])",
|
||||
"match": "\\b(\\.)\\s*(?<![@\\$#%])(?:([A-Z_][A-Z_0-9]*)|([A-Za-z_]\\w*))\\b(?![(])",
|
||||
"captures": {
|
||||
"1": { "name": "punctuation.accessor.gdscript" },
|
||||
"2": { "name": "constant.language.gdscript" },
|
||||
|
||||
Reference in New Issue
Block a user