mirror of
https://github.com/neovim/neovim.git
synced 2026-08-31 03:13:48 +00:00
fix(snippet): cancel session on ESC in insert-mode #41555
Problem: If a snippet does not have a placeholder, we use insert mode instead of select mode. From here <Esc> leaves the session and highlight active. Solution: Cancel the session on <Esc>.
This commit is contained in:
@@ -480,7 +480,7 @@ local function setup_autocmds(bufnr)
|
||||
desc = 'Stop the snippet session when leaving select mode',
|
||||
buf = bufnr,
|
||||
}, function(args)
|
||||
if args.match ~= 's:n' then
|
||||
if args.match ~= 's:n' and args.match ~= 'i:n' then
|
||||
return
|
||||
end
|
||||
vim.schedule(function()
|
||||
|
||||
@@ -280,6 +280,16 @@ describe('vim.snippet', function()
|
||||
poke_eventloop()
|
||||
eq(false, exec_lua('return vim.snippet.active()'))
|
||||
eq(0, #api.nvim_buf_get_extmarks(0, ns, 0, -1, {}))
|
||||
|
||||
feed('dal')
|
||||
test_expand_success({ 'local $1 = ${2:value}' }, { 'local = value' })
|
||||
eq('i', fn.mode())
|
||||
eq(true, exec_lua('return vim.snippet.active()'))
|
||||
t.neq(0, #api.nvim_buf_get_extmarks(0, ns, 0, -1, {}))
|
||||
feed('<Esc>')
|
||||
poke_eventloop()
|
||||
eq(false, exec_lua('return vim.snippet.active()'))
|
||||
eq(0, #api.nvim_buf_get_extmarks(0, ns, 0, -1, {}))
|
||||
end)
|
||||
|
||||
it('stop session when jumping to $0', function()
|
||||
|
||||
Reference in New Issue
Block a user