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

Escaping \\ in snippet using \\\\ outputs only one backslash #33933

Closed
LCAR979 opened this issue Sep 7, 2017 · 1 comment
Closed

Escaping \\ in snippet using \\\\ outputs only one backslash #33933

LCAR979 opened this issue Sep 7, 2017 · 1 comment
Assignees
Labels
*duplicate Issue identified as a duplicate of another issue(s) *question Issue represents a question, should be posted to StackOverflow (VS Code) snippets

Comments

@LCAR979
Copy link

LCAR979 commented Sep 7, 2017

  • VSCode Version: 1.15.1, Commit 41abd2
  • OS Version: Ubuntu 16.04

Steps to Reproduce:

  1. Insert the following code snippet to latex.json (which is where user's tex snippet goes)
    Or by clicking File -> Preferences->User Snippets and search tex.
	"Input a multiline eqn": {
		"prefix": "eqnmultiline",
		"body": [
			"\\[",
			"\t\\begin{array}{lcl}",
			"\t\t ${1:foo} & = & ${2:foo} \\\\",
			"\t\t & = & ${3:foo} \\\\",
			"\t\t & = & ${4:foo} \\\\",
			"\t\\end{array}",
			"\\]",
			"$0"
		],
		"description": "Input a multiline eqn"
	}

  1. In a demo.tex, type eqnmultiline which will insert a code snippet as follows:
   \[
        \begin{array}{lcl}
             foo & = & foo \
             & = & foo \
             & = & foo \
        \end{array}
    \]

And I'm expecting a \\ at the end of the three foo lines, which I use \\\\ to escape. But the result is one \ at each line.
Snippet Grammer says using \ to escape \. So I'm wondering if this is a bug.

Reproduces without extensions:
Correct Sorry for not testing using suggested code --disable-extensions before because I missed that line in comment . Tried it today and after disabling extensions, I cannot insert tex snippets even through Command Palette. It tells me there are no entries to pick from

@vscodebot vscodebot bot added the new release label Sep 7, 2017
@vscodebot vscodebot bot added the editor label Sep 7, 2017
@alexdima alexdima assigned jrieken and unassigned alexdima Sep 12, 2017
@jrieken jrieken added snippets *duplicate Issue identified as a duplicate of another issue(s) *question Issue represents a question, should be posted to StackOverflow (VS Code) labels Sep 12, 2017
@jrieken
Copy link
Member

jrieken commented Sep 12, 2017

Sorry for the mess... This dupe #32020 (comment) but in short this is the problem

  • In TextMate you can but must not escape a backslash with a backslash, so to insert 1 backslash have either \ or \\
  • In JSON you must escape a backslash with another backslash, so to insert 1 backslash have either \\ or \\\\, to insert 2 \\\\\\\\

There are idea to move away from JSON for this and other escaping challenges...

@jrieken jrieken closed this as completed Sep 12, 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
*duplicate Issue identified as a duplicate of another issue(s) *question Issue represents a question, should be posted to StackOverflow (VS Code) snippets
Projects
None yet
Development

No branches or pull requests

4 participants