Open duwejeferson opened 1 year ago
Interesting find. I was able to reproduce your issue - when using the command palette UI to save, entering in \n
as the replace pattern results in the settings JSON being "replacePattern": "\\n"
If manually editing the settings JSON, this would work:
{
"label": "written \\n to newline",
"regExp": "\\\\n",
"replacePattern": "\n",
"regExpFlags": "g"
},
So at least there's a workaround.
Unfortunately there might not be a way to fix the command palette because of the way vscode's showInputBox
works. Entering \
will always result in the string being \\
when using the input box.
I could add an extra step in the code to replace all \\
with \
before saving, but I'm not sure if that would be expected behaviour for users.
@phitranphitranphitran Thanks for the fast response.
Agreed, this could be a breaking change. Perhaps an option to change the behaviour could be added?
Or even easier, make it clear in the docs about the command palette default behaviour.
I've downloaded the extesion to use it with a very particular case where i replace \n (written) with a new line.
After creating the RegExp, it ended being:
But executing this, just make it the same as before, as the replacement is scaped too.
I think the replacement pattern shouldn't be escapped when saving with the command palette.
It ended up working after removing the scape in "replacePattern".