ultisnips icon indicating copy to clipboard operation
ultisnips copied to clipboard

Wrong final cursor position in nested auto-trigger snippets

Open PhyX-Meow opened this issue 3 years ago • 4 comments

Let these be tex.snippets

snippet mk "Math" iA
\($1\)$0
endsnippet

snippet xx "foo" iA
aha
endsnippet

snippet ** "foo" iA
aha
endsnippet

And these be .vimrc

let $PlugPath = '~/.vim/plugged'

call plug#begin($PlugPath)

Plug 'sirver/ultisnips'
    let g:UltiSnipsExpandTrigger = '<tab>'
    let g:UltiSnipsJumpForwardTrigger = '<tab>'
    let g:UltiSnipsJumpBackwardTrigger = '<s-tab>'

Plug 'neoclide/coc.nvim', {'branch': 'release'}

call plug#end()

Expected behavior: When I press both mk**<tab> and mkxx<tab>, the cursor should be after ')'

Actual behavior: When I press mkxx<tab>, the cursor eventually stays on ')'. When I press mk**<tab>, the cursor goes after ')' as expected.

Steps to reproduce Put the three snippets above into tex.snippets and press the keys as discribed.


  • Operating System: Manjaro Linux in wsl2
  • Vim Version: VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Sep 17 2020 21:54:53) 包含补丁: 1-1704
  • UltiSnips Version: 7941f98337564d4e86cf2b7467b64def4d212794
  • Python inside Vim: python3.8.5
  • Docker repo/vimrc:

PhyX-Meow avatar Oct 02 '20 08:10 PhyX-Meow

https://github.com/lervag/dotvim/blob/master/coc-settings.json fix the issue for me, don't know which line takes the effect.

PhyX-Meow avatar Oct 03 '20 05:10 PhyX-Meow

Same issue here. I tried to put the coc-setting.json file in the .vim folder, but it still doesn't work.

zhuosongz avatar Oct 04 '20 06:10 zhuosongz

Same issue here. I tried to put the coc-setting.json file in the .vim folder, but it still doesn't work.

You may not copy the whole file. Here's what in my coc-settings.json

{
  "diagnostic.displayByAle": true,
  "diagnostic.refreshAfterSave": true,
  "suggest.enablePreview": true,
  "suggest.minTriggerInputLength": 3,
  "suggest.snippetIndicator": "[+] ",
  "suggest.timeout": 1000,
  "suggest.removeDuplicateItems": true,
  "coc.source.ultisnips.enable": false,
  "coc.preferences.useQuickfixForLocations": true
}

And I have coc-ultisnips installed. By the way, I Plug coc-nvim before ultisnips, maybe you can try it.

PhyX-Meow avatar Oct 06 '20 07:10 PhyX-Meow

Thank you very much for your reply. However, I am using vim-snippet and Ultisnipet, not using coc-nvim. Unfortunately, this solution doesn't work for me.

zhuosongz avatar Oct 19 '20 04:10 zhuosongz

Somehow this seems fixed in latest version of Ultisnips and coc.nvim, with latest configuration on https://github.com/neoclide/coc.nvim I'll do more test later then close this if really fixed.

PhyX-Meow avatar Aug 19 '22 03:08 PhyX-Meow

The bug completely disappears now on my environment, I don't quite know why, maybe thanks to update of coc.nvim? Anyway, closing this. If someone run into same issue, I'm glad to share my configuration to you.

PhyX-Meow avatar Aug 29 '22 15:08 PhyX-Meow