coc-snippets icon indicating copy to clipboard operation
coc-snippets copied to clipboard

Backspace in nested snippets causes skipping over current snippet

Open gerritwellecke opened this issue 10 months ago • 2 comments

I have the following two snippets for LaTeX:

snippet equ "Equation" bA
\begin{equation}
	${1:${VISUAL}}
\end{equation}
$0
endsnippet

context "math()"
snippet // "Fraction" iA
\\frac{$1}{$2}$0
endsnippet

A long time ago I got used to using tab for completion and snippets, so my init.vim has the following:

inoremap <silent><expr> <TAB>
      \ coc#pum#visible() ? coc#pum#next(1) :
      \ coc#expandableOrJumpable() ? "\<C-r>=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\<CR>" :
      \ CheckBackspace() ? "\<TAB>" : coc#refresh()

function! CheckBackspace() abort
  let col = col('.') - 1
  return !col || getline('.')[col - 1]  =~# '\s'
endfunction

This is supposed to either give me the next suggested completion from coc or jump through the snippet. I don't really understand this, just took it from the coc (or cog-snippets) readme, so my problem might lay in this.

When I type a new equation and then inside that a fraction I would expect to get through the entire fraction and then be able to continue writing my equation. However, when I use a backspace within the fraction, the next time I press TAB to jump further, my cursor ignores the rest of that snippet and just jumps on within the equation snippet: Problem

gerritwellecke avatar Aug 17 '23 09:08 gerritwellecke