atom / snippets

Atom snippets package
MIT License
205 stars 100 forks source link

\$ followed by a number doesn't get escaped properly #197

Closed BojanStipic closed 8 years ago

BojanStipic commented 8 years ago

For example, I have the following snippet for GAS:

'.source.asm.x86_64':
  'Input':
    'prefix': 'in'
    'body': """
        movl \$3, %eax
        movl \$0, %ebx
        leal ${1:string}, %ecx
        movl ${2:size}, %edx
        int \$0x80
    """

Expected behavior: dollar sign gets escaped and it generates:

movl $3, %eax
movl $0, %ebx
leal string, %ecx
movl size, %edx
int $0x80

Instead, \$3 and \$0 creates a new tab stop.

50Wliu commented 8 years ago

@BojanStipic Can you try two backslashes? Eg \\$3.

BojanStipic commented 8 years ago

@50Wliu It does work correctly with two backslashes, but I am now curious why would I need two backslashes? I can't find documentation where that is stated.

50Wliu commented 8 years ago

@BojanStipic CSON escapes the first backslash before passing it to the snippet parser, which then escapes the second backslash, which is why you need two. In fact, in order to actually display a backslash, you need to quadruple-escape it: \\\\ :P.