SirVer / ultisnips

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

LaTeX snippet misfires when it spans multiple lines wrapped by textwidth setting #1510

Open TryerGit opened 1 year ago

TryerGit commented 1 year ago

Given snippet:

snippet mm "Inline Math" wA
\\( $1 \\) $0
endsnippet

which inserts inline math mode in LaTeX: \( | \) where cursor position is |

and following .vimrc:

"-------------Load Plugins------------------
if empty(glob('~/.vim/autoload/plug.vim'))
    silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
        \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
    autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')
Plug 'lifepillar/vim-mucomplete'
Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
Plug 'lervag/vimtex'
call plug#end()
"---------------End Plugins added-----------------------
"----------- UltiSnips triggering-------------
let g:UltiSnipsExpandTrigger = '<C-a>'
let g:UltiSnipsJumpForwardTrigger = '<C-a>'
let g:UltiSnipsJumpBackwardTrigger = '<C-d>'
let g:UltiSnipsEditSplit="vertical"
let g:UltiSnipsSnippetDirectories=[$HOME.'/.vim/UltiSnips']
"-----------End ultisnips--------------------
"---------Begin MuComplete Setup-----------
  set completeopt+=menuone
  set completeopt+=noselect
  set belloff+=ctrlg
  let g:mucomplete#enable_auto_at_startup = 1
"---------End MuComplete Setup-------------
set textwidth=79
set colorcolumn=79

type mm close to column number 79/78 so that the snippet expansion breaks across two lines.

Expected behavior:

If broken into two lines, the snippet should expand like so:

\(<col 79>
|\)

Actual behavior:

instead it expands like so

\(<col 79>
\|)

where the cursor position after snippet expansion is between the closing \ and )

I checked with the VimTeX repo and it seems to not be an issue with that plugin. The author/maintainer there indicates that it could possibly be an issue with UltiSnips. See here

Steps to reproduce

  1. Please see above. An explanatory animated gif is below:

issue