draivin / hsnips

HyperSnips: a powerful snippet engine for VS Code, inspired by vim's UltiSnips
MIT License
148 stars 23 forks source link

Escaped backslash not showing before right curly brace #160

Open ahan98 opened 1 year ago

ahan98 commented 1 year ago

The escaped backslash does not appear in the snippet return value \\}.

Minimal example:

  1. Create latex.hsnips
  2. Define the following snippet
snippet foo A
`` rv = `\\}` ``
endsnippet
  1. In somefile.tex, type foo
  2. Expected: \}, Received: }

To actually output \}, the RHS needs to be \\\\}.

Also, the error does not occur for: space-separated \\ }; individual characters \\ or }; other braces, e.g., \\{.

Fredlague commented 5 months ago

Pretty sure this is intended behavior. The first \ is to escape the } in the hsnips language. Then you need to escape it again so regex spits it in the snippet language, then you regularly escape it inside your regex. Triple escape.

This is also how it works in json (for the Conceal extension).