Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snippet expansion drops escaped backslashes. #32020

Closed
brunnerh opened this issue Aug 4, 2017 · 3 comments
Closed

Snippet expansion drops escaped backslashes. #32020

brunnerh opened this issue Aug 4, 2017 · 3 comments
Assignees
Labels
snippets under-discussion Issue is under discussion for relevance, priority, approach

Comments

@brunnerh
Copy link

brunnerh commented Aug 4, 2017

  • VSCode Version: Code 1.14.2 (cb82feb, 2017-07-19T23:26:08.116Z)
  • OS Version: Linux x64 4.12.3-1-ARCH

For snippets with escaped backslashes more backslashes are required than expected. For example, if the snippet has the format "a\\b" with n backslashes the outputs for various n are as follows:

2  -> a\b
4  -> a\b
6  -> a\\b
8  -> a\\b
10 -> a\\\b
12 -> a\\\b
...

Given that the output for 2 backslashes is identical to the output with 4 backslashes suggests that something is off here.

Steps to Reproduce:

  1. Create a snippet like this:
"Test": {
	"prefix": "test",
	"body": "a\\\\b"
}
  1. Insert snippet.
  2. Check output for number of backslashes.
  3. Expected: 2 | Actual: 1

Reproduces without extensions: Yes

@kieferrm kieferrm added snippets bug Issue identified by VS Code Team member as probable bug labels Aug 4, 2017
@jrieken
Copy link
Member

jrieken commented Aug 21, 2017

Expected: 2 | Actual: 1

Actually, no. Apologies, but it's messy. Textmate escapes a backslash with a backslash, so to insert one backslash, \ or \\ can be typed. Now comes, JSON which also needs a backslash to escape a backslash making this \\ or \\\\

@jrieken jrieken added under-discussion Issue is under discussion for relevance, priority, approach and removed bug Issue identified by VS Code Team member as probable bug labels Aug 21, 2017
@brunnerh
Copy link
Author

That is rather inconsistent and confusing, but if nothing can be done about this anyway because this is an issue with an external component this might as well be closed.

@jrieken
Copy link
Member

jrieken commented Aug 22, 2017

That is rather inconsistent and confusing, but if nothing can be done about this anyway because

Yeah, unfortunate. #25661 is about allowing to write snippets in another non-json format. That would remove the need for double backslashes. However, the backslash vs escaped backslash issue is how text mate works.

Closing this with the pointer towards #25661

@jrieken jrieken closed this as completed Aug 22, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
snippets under-discussion Issue is under discussion for relevance, priority, approach
Projects
None yet
Development

No branches or pull requests

3 participants