vscode-textmate icon indicating copy to clipboard operation
vscode-textmate copied to clipboard

Wrong backreference escaping

Open RedCMD opened this issue 1 year ago • 0 comments

When using backreferences across begin-end/while rules a bunch of regex characters get escaped in the process

The escape characters differ between VSCode TextMate and the official TextMate 2.0

TextMate 2.0 escapes: https://github.com/textmate/textmate/blob/master/Frameworks/parse/src/parse.cc#L120 \|([{}]).?*+^$ VSCode TextMate escapes: https://github.com/microsoft/vscode-textmate/blob/main/src/utils.ts#L160 \|([{}]).?*+^$-,# \t\n

"begin": "^(.+)$",
"end": "[\\1]+",
"name": "string"

That grammar will match differently between VSCode and TextMate2.0 on the file:

a-z
bcd
a-z
hij

VSCode: image

TextMate2.0: image

RedCMD avatar Sep 22 '24 04:09 RedCMD