snippets icon indicating copy to clipboard operation
snippets copied to clipboard

Snippets do not work after punctuation

Open djpowers opened this issue 9 years ago • 3 comments

Hello,

I noticed that when trying to tab-complete an ERB tag, it does not work if the cursor is directly after HTML tags with no whitespace, and seemingly any other punctuation. I wasn't sure if this was intentional, or a limitation of some sort.

I'm using Atom 0.210.0 on Mac OS X 10.10.3.

To reproduce:

  1. Open a new document and set the syntax to HTML (Rails).
  2. Autocomplete a span tag, which places the cursor in between: <span></span>
  3. Type = and then press tab to trigger the snippet.

Expected behavior: An ERB tag would be created inside the span, like so:

<span><%=  %></span>

Actual behavior: The cursor jumps ahead to after the closing tag without creating the ERB tag:

<span>=</span>

Triggering this snippet works if it directly follows whitespace or an alphanumeric character, so I wasn't sure if following symbols should work the same.

Please let me know if I missed some documentation, or if this should be reported elsewhere. Thank you.

djpowers avatar Jun 19 '15 21:06 djpowers

works for letters now, but still no love for a snippet like $$,I would love to have this fixed.

Oblik-Design avatar Jan 13 '17 17:01 Oblik-Design

Having the same issue in Atom 1.20.

dankimio avatar Sep 19 '17 09:09 dankimio

This is a complex issue that arises when a snippet’s prefix begins with punctuation rather than a letter. When the user hits Tab and the cursor is preceded by several punctuation marks in a row (>= in this example), the snippets package looks for snippets whose prefixes start with > instead of = because there’s no obvious “word” boundary to help it out.

It looks for such a boundary because if a snippet has a prefix ff, we don't want it to get invoked if the user types off and then presses Tab. But when the entire “word” is just a string of non-word characters, we shouldn’t really care about this potential false positive, so I think I’ve got an idea of how we’d fix this.

savetheclocktower avatar Sep 23 '18 17:09 savetheclocktower