atom/snippets

Snippet placeholder bug

zlangley opened this issue · 4 comments

I'm trying to write a snippet for def in Scala:

'method':
  'prefix': 'def'
  'body': 'def ${1:method}${2:(${3:arg}: ${4:Type})} = {\n\t$0\n}'

After typing in the method name and hitting tab, the parentheses and arguments should be highlighted, but Atom highlights the most of the method name I typed too (everything but the first character).

Hmm... tried writing a test to confirm this bug, but the test passed. Any idea what's going on? When I use this snippet in practice, the selected buffer range after typing foo and hitting tab is [[0, 5], [0, 18]].

Here is the diff for the test I wrote: https://gist.github.com/zlangley/9301362

I think this could be a bug in the markers API provided by atom/text-buffer.

The text is bleeding over from one tab stop to another since there is no text in between them.

vigo commented

When I press tab to jump next placeholder, it looses cursor position. Next place holder starts from very early, like;

<h1>${1:Text}${2:<small>$3</small>}</h1>$0

First match is ok, type something, then press tab then boom :)

Is there an issue already in https://github.com/atom/text-buffer for this? I know this affects atom/language-php#27 and likely other snippets. Thanks!