ultisnips
ultisnips copied to clipboard
expand_anon results in cursor being one space in front of first tabstop
Expected behavior: The cursor starts on the same space as the tabstop and respects leading whitespace
Actual behavior: The first tabstop places the cursor to the left of the tabstop marker

Steps to reproduce
global !p
def create_dotpoint_placeholders(snip):
try:
placeholders_amount = int(snip.buffer[snip.line].strip())
except:
placeholders_amount = 1
# erase current line
snip.buffer[snip.line] = ''
anon_snippet_body = ''
for i in range(placeholders_amount):
anon_snippet_body += '• $' + str(i+1) + '\n'
# expand anonymous snippet
snip.expand_anon(anon_snippet_body)
endglobal
post_jump "create_dotpoint_placeholders(snip)"
snippet "stnd\.(\d?)" "Adds dot-points" br
`!p snip.rv = match.group(1)`
endsnippet
The intent of this snippet is to enter stnd.3
, which enters 3 dot points to tab between on different lines. Entering just stnd.
will enter a single dot point.
Current workaround I'm able to work around this problem by inserting default text into the anonymous snippet:
anon_snippet_body = ''
for i in range(placeholders_amount):
anon_snippet_body += '• ${' + str(i+1) + ':description}\n'
This highlights the description
, and respects the leading whitespace.
Confirmed. Thanks for the bug report!