L3MON4D3 / LuaSnip

Snippet Engine for Neovim written in Lua.
Apache License 2.0
3.27k stars 232 forks source link

Jumping out of nested snippets #1206

Open ccatrett opened 1 month ago

ccatrett commented 1 month ago

Hi, new nvim user trying to figure out how to use luasnips!

I have the following issue when trying to jump out of nested/iterated snippets with a minimal example:

s('_', {
    t('_{ '), i(1), t(' }')
})

which expands an underscore character to an underscore with curly braces.

Expected Behavior

After expanding more than once in a nested snippet, I want to be able to jump all the way back out, so for example,

_*   -->   _{ * }    -->   _{  _{ * } }   -->   _{  _{ ustext }* }   -->   _{ _{ text } }*

where * represents my cursor position, and the arrows indicate a jump or expansion.

Actual Behavior After expanding more than once, my cursor gets stuck between the two closing curly braces:

_*   -->   _{ * }    -->   _{  _{ * } }   -->   _{  _{ text }* }   -->   _{ _{ text }* }    -->   _{ _{ text }* } 

no matter how many times I expand or jump.

The steps to reproduce would simply be to recreate this minimal example.

I thought that #1070 may be similar, but I couldn't figure out what the intended solution with the conditions approach was.

Is this intended behavior? How can I mitigate this so that I can achieve the expected behavior?

L3MON4D3 commented 1 month ago

Hi! :) Usually you should be able to jump out of the first snippet as well... at least this is working on my end. What version of luasnip are you using? Could you check the log for suspicious entries? Do ls.log.set_loglevel("info") before expanding the snippets, and check the log with ls.log.open() (ls being require("luasnip"))