godotengine / godot-vscode-plugin

Godot development tools for VSCode
MIT License
1.48k stars 148 forks source link

`"patterns"` array does not work with `"match"` TextMate #542

Closed RedCMD closed 4 months ago

RedCMD commented 7 months ago

Godot version

NA

VS Code version

1.84.2

Godot Tools VS Code extension version

1.3.1

System information

Windows 11

Issue description

"patterns" does not work with "match" escape characters will not get tokenized did you mean to use begin/end instead?

"begin": "\""
"end": "\""

https://github.com/godotengine/godot-vscode-plugin/blob/f65033c6260e9eb5256d2c02a51a036c88d2ceb9/syntaxes/GDResource.tmLanguage.json#L201-L214

I don't recommend putting the string contents in a capture group and using "patterns" inside "captures" as that incurs a medium performance hit in VSCode TextMate EDIT: "name" inside "captures" is fine

If Godot shouldn't support escape characters inside a string then the "patterns" array can be safely removed

Steps to reproduce

Create a string with escape characters inside it \\ [ "string\\bar" ]

DaelonSuzuka commented 7 months ago

Good catch, thank you.

I don't recommend putting the string contents in a capture group and using "captures" as that incurs a medium performance hit in VSCode TextMate

How do you know that? I've been looking for resources on TextMate best practices for a while, but there isn't much content in this area.

RedCMD commented 7 months ago

but there isn't much content in this area.

heres some links I've used:

How do you know that?

Through my own personal testing https://github.com/microsoft/vscode-textmate/issues/167 I was confused as to why some rules were causing more lag than others for seemingly no reason turned out simply just using a "patterns" array inside "captures" was causing the lag I suspect its doing an inefficient string copy? you wont see the performance difference much until you try tokenizing 5000+ character lines or 10,000+ line files EDIT: Using "name" inside "captures" is fine

DaelonSuzuka commented 7 months ago

Holy shit, you're the tmLanguage.json syntax extension guy! That's an excellent tool, thank you for building it!

\

Fantastic, thank you! Those are going in my list right away.

I was already planning to do some performance testing soon[0], so this is really useful stuff.

[0] I'm building a code formatter for GDScript using the tm grammar and vscode-textmate