ultisnips
ultisnips copied to clipboard
`post_expand` & `post_jump` cause nested snippets cursor position/order error.
Snippets Code
global !p
def test(snip):
before = snip.buffer[snip.line][:snip.snippet_start[1]]
after = snip.buffer[snip.line][snip.snippet_end[1]:]
snip.buffer[snip.line] = ''
snip.expand_anon(before + '[$1, $2]$0' + after)
endglobal
snippet t "Description" i
($1, $2)$0
endsnippet
snippet a "Description" i
[$1, $2]$0
endsnippet
post_expand "test(snip)"
snippet b "Description" i
endsnippet
post_jump "test(snip)"
snippet c "Description" i
endsnippet
Expected behavior:
Cursor can jump in right position in a right order like the first line in Demo.
Actual behavior:
post_expand
can have correct cursor position. However, its cursor order is incorrect. Shown in the second line in Demo.
post_jump
can have correct cursor order. However, its cursor position is incorrect and it will cause strange selection behavior as well. Shown in the third line in Demo.
Since the tabstops number is not sure, snippets using post
action is more general. So I wonder that if there is a way to avoid this issue.
Steps to reproduce
- Create the above minimum snippets file
- Type as above