LuaSnip
LuaSnip copied to clipboard
NEW IDEA OF SOLVING luasnip.jump(1) will jump back's PROBLEM!!!!
#532
I've just got an idea. If we leave the old snip, the older snippets position is still there. If we want to jump back, we can call luasnip.jump(-1) to jump to an older position.
if we have the jumpable old snippet position and we're now inside the new snippets, the new snippets should have the higher priority so when we call luasnip.jump(-1) it just jump backward in the new snippets unless reach the beginning of the snippets.
If we reach the beginning of the new snippets, and we call luasnip.jump(-1) we will back to old snippets.
For example, in python:
old snippets ------------------------
for $1 in $2 :
$3
new snippets ------------------
for $4 in $5 :
$6
$7 <------------ we are here :D
------------------------------------
now if we call luasnip.jump(-1), we jump to $6, then call jump(-1), we jump to $5, then call jump(-1), we jump to $4, then call jump(-1), we jump to $3 ... $2 ... $1 I think this will perfectly solve the problem of jump(1) will jump back because the reason of accidently jump back to last snippets position is most people just use jump(1) to jump to next place but jump(1) will jump into the old snippets position.
so if we change jump(-1)'s behaviour, this problem might to solved perfectly :D
Mhm, yeah that's probably more intuitive than the current behaviour. (This specific setup is even possible currently, but only if each snippet is "jumped through" completely) We only have to take care to not do this if the new snippet is expanded inside the old snippet, for example we wouldn't want
for $1{var[$4:$5]} in $2
$3
with the snippets for $1 in $2 \n\t$3 and var[$1:$2]
The implementation of your idea would just include detecting whether the new snippet is outside the old snippet, if it is, it can be put before or behind it.
Might make sense to make this the new default, it will immediately fix all these problems with not jumping through snippets entirely
Ok, I'll try to think deeper of this idea, once I get new idea, I will inform you :D :+1:
Oh, no, I think it's possible to implement your idea :D Just wanted to highlight that it depends on where the new snippet is expanded (before/inside/behind the old snippet)
Oh, i get it! Appreciate for your reply :D :+1:
Bit more than a year later, ad089ed implements what you wanted, I think :D
bravo!!! appreciate for your excellent working sir!