SirVer / ultisnips

UltiSnips - The ultimate snippet solution for Vim. Send pull requests to SirVer/ultisnips!
GNU General Public License v3.0
7.51k stars 690 forks source link

Unexpected jump to select mode, with other completion engines. #1380

Open jfab20 opened 3 years ago

jfab20 commented 3 years ago

I have reported this issue before but with coc-nvim, it is the following one: https://github.com/SirVer/ultisnips/issues/1327. However I have realized this issue is present with every completion engine I have tried (nvim-compe and deoplete) so I think it is an Ultisnips bug.

Basically, when I had coc-nvim completion on, and I had this snippet:

snippet test "test" iA
test{$1}{$2}$0
endsnippet

Then nesting the snippet inside itself would create an error when I tried to get out of it.

Expected behavior:

Nesting arbitrary test snippets and then pressing tab repeatedly takes me out of the whole expression.

Actual behavior:

When I type test, It expands to text{}{} and if I press tab 2 times, it takes me out of the parenthesis, and I can even add text in between, all fine.

Now suppose I write text -> text{}{} and then in the first placeholder I write test again. I want test{test{}{}}{}. And then I expect that if I typetab two times, it takes me out of the first text{}{} (which it does ) BUT when I type tab another time, i see that vim starts select mode and selects the place holder test{}{}, like this:

image

Steps to reproduce

I thought this was a coc-nvim problem, and in fact the issue I submitted couldn't really progress because of all the parts that constituted the problem (say, coc-nvim, nodejs, npm). However today I decided to install nvim-compe, another completion engine, and the problem is still present, so I think this issue is from Ultisnips. I have changed operating system (to arch), changed from vim to neovim and I use a different completion engine, and the problem is still present.

To reproduce this just install one of the following completion engines:

Then install Ultisnips, and create the snippet I provided. Then just nest like 5 test snippets and press tab repeatedly.


fecet commented 3 years ago

It's possible to disable completion engine disable when we in math context, say, set b:coc_suggest_disable, and enable otherwise? I'm a vim fresher and have no idea how to implement it.

jfab20 commented 3 years ago

I really don't know, but hopefully this gets fixed @SirVer do I need to give other examples or maybe my vimrc ? This issue is almost two weeks old and no response is given :(.

jfab20 commented 3 years ago

@SirVer The issue disappears when you deactivate the A option in the snippet.

jfab20 commented 3 years ago

If a minimal vimrc is required, here it is: (in this case I use deoplete, feel free to use any other completion engine)

call plug#begin()
Plug 'SirVer/ultisnips'
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
call plug#end()
let g:deoplete#enable_at_startup = 1
let g:UltiSnipsExpandTrigger="<c-j>"
let g:UltiSnipsJumpForwardTrigger="<c-j>"
let g:UltiSnipsJumpBackwardTrigger="<c-k>"

with this snippet

snippet frac "Fraction" iA
\frac{${1:${VISUAL}}}{$2}$0
endsnippet

and then just try to nest them one after the other

jfab20 commented 3 years ago

Also, I think this has something to do with the popup menu because, when using the completion engine ncm2, I have set the following options:

set completeopt=noinsert,menuone,noselect

and I get a different bug. Now, ultisnips doesn't go into select mode but jumps to the wrong placeholders randomly (sometimes it jumps backwards when I press <c-j>, etc...). This behavior is not present when no autocompletion engine installed