Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backspace in nested snippets causes skipping over current snippet #339

Open
gerritwellecke opened this issue Aug 17, 2023 · 2 comments
Open
Labels
bug Something isn't working

Comments

@gerritwellecke
Copy link

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

@chemzqm chemzqm added the bug Something isn't working label Sep 5, 2023
@chemzqm
Copy link
Member

chemzqm commented Sep 5, 2023

Something went wrong when you remove the inner snippet.

@gerritwellecke
Copy link
Author

Same behaviour can be observed when only a single backspace is entered (doesn't have to be the full snippet that is deleted).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants