Avoid double tab to exit a snippet


#1

Take the following snippet

'.source.js':
  'Snippet Name':
    'prefix': 'hello'
    'body': 'Hello World! $1'

First push on “tab” : The snippet is activated and my cursor moves to $1. (expected behavior)
Second push on “tab”: I expect my cursor to move right as a normal “tab” since I’m at the end of the snippet. but nothing happens.
third push on “tab”: Now I get my cursor to “tab”.

Actually there is something happening on the second tab push. From my tests it seems that the snippets packages considers 1 as {1:} as such, after the first push on tab, There is an invisible selection made on $1.

This behavior used to be different I tracked the change at atom version 1.25 with this specific commit:

My question is:

I heavily rely on snippets and I find this situation of “double tabbing” annoying. Am I the only one in this situation ?

Suggested solution: consider $0 as a special variable that makes you exit “snippet mode”


#2

Why do you have the tab stop there in the first place if you don’t want to use it?


#3

I used the simplest example for the sake of undertanding.

After a first “tab” I expect my cursor to move to $1 and exit “snippet mode” (so far I need to double tab).

I’m aware that this behavior would surely have side effects (for example rollback to previous placeholder in case of $1 $2 $3).

That’s why first I’d like to know if there are people who feel like me and second suggest to use $0 as a “snippet mode exit” variable


#4

Looks like a but to me. Have you opened an issue?


#5

Hi Idleberg, Yes I just posted an issue today.

I included a solution in the report. The solution worked in the different scenario I tested manually. I would gladly appreciate if somebody more experienced than me could cross-check it though.