bew / dotfiles

All my dotfiles in one place!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug in Ultisnips ? Using 'complex' nested snippets and jumping to placeholders

bew opened this issue · comments

Given these snippets (for ultisnips files)

snippet vis "VISUAL placeholder with default value" w
\$\{VISUAL${1:${2:default}${3:/${4:transform}/}}\}
endsnippet

snippet n "Numeric placeholder with default value" w
${$1:$2}
endsnippet

(TODO: try to reduce snippets code to minimal that still reproduce the bug)

Given:

  • <tab> is the snippet expansion binding
  • <next> selects the next placeholder
  • [abc] means abc is the selected text (in select mode)
  • ab[]c the cursor is between b and c (in insert mode)

Doing the following actions:
n<tab>1<next>vis<tab><backspace><next><next><next>

Here is what I see at each step:

  • do: n<tab>
    out: ${[]:} (in snippet n)
  • do: 1<next>
    out: ${1:[]} (in snippet n)
  • do: vis<tab>
    out: ${1:${VISUAL[default/transform/]}} (in snippet vis)
  • do: <backspace><next>
    out: ${1:${VISUAL}[]} (in snippet vis ? or snippet n ?)
  • do: <next> (I want to get out now!)
    out: ${1:[${VISUAL}]} (:warning: this is unexpected... Still in snippet n ?)
  • do: <next> (I guess I'm still in snippet n, I want to get out now!)
    out: ${1:j} (note: Alt-j (<M-j>) is my <next> snippet; and now I'm not in a snippet anymore as subsequent Alt-j goes to the next line like a <esc>j would do when not in a snippet)
    This would mean I was not in a snippet when doing that last <next> ? How do I get out then ?

I wanted: ${1:${VISUAL}}[] ([] is the cursor in insert mode)

I should migrate to LuaSnip instead! (neovim 0.5 !!)