Issue with Dash snippets


#1

Dash snippets allow you to include a special character to indicate where the cursor should be placed after you insert the snippet. This works fine in Atom as long as the snippet is inserted at col 0 – but if the snippet in inserted at any other column, Atom counts spaces from column 0 anyway, deletes whatever character happens to be at supposed cursor point, and leaves the cursor there. For what it’s worth, the same issue exists in Sublime Text 3 (but not in any other code editor I’ve tried).


#2

Can you give an example? I’m trying to visualize, but I’m not getting it :blush:


#3

Sure! So here’s a typical Dash snippet:
<div class=“section” id="@cursor">
@clipboard
</div>

which inserts the clipboard contents in place of @clipboard, and puts the cursor where @cursor is.
If I insert this at column 7 instead of column 0, Atom deletes the “o” in “section” and locates the cursor there, while leaving some kind of gremlin where @cursor is. does that make sense?


#4

Ok, thank you … I understand now.

Unfortunately, I don’t really have any suggestions though. It appears that Dash uses OS X’s Accessibility features to perform its snippet functionality, but I don’t have an easy way of verifying that. If you can shed some light on how it manages to expand its snippets in another program then maybe I can come up with some other ideas?


#5

Thanks - I’ll ask the developer and see what I can find out.


#6

Here’s what I got back from Kapeli – hope you can do something with it:

I use Accessibility if the app is accessible (which ST and Atom aren’t).

If Accessibility is not possible, Dash blindly sends key events to try to reposition the cursor where the @cursor was. The problem is that when Dash pastes the snippet Atom adds indentation to it and the number of keys required no longer match. There’s no way for Dash to know your current indentation level without Accessibility, so there’s nothing really to be done.

I’ve tried to fix this problem in other apps as well with no luck. I don’t think there’s anything Atom can do, apart from supporting Accessibility.

My recommendation is not to use the @cursor placeholder in non-accessible apps when indentation is involved. Sorry!