mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
fix(lsp): do not cancel snippet when selecting placeholder (#25835)
This commit is contained in:
parent
8405649f92
commit
0fe0cf5ada
@ -278,6 +278,11 @@ local function setup_autocmds(bufnr)
|
|||||||
desc = 'Update snippet state when the cursor moves',
|
desc = 'Update snippet state when the cursor moves',
|
||||||
buffer = bufnr,
|
buffer = bufnr,
|
||||||
callback = function()
|
callback = function()
|
||||||
|
-- Just update the tabstop in insert and select modes.
|
||||||
|
if not vim.fn.mode():match('^[isS]') then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local cursor_row, cursor_col = cursor_pos()
|
local cursor_row, cursor_col = cursor_pos()
|
||||||
|
|
||||||
-- The cursor left the snippet region.
|
-- The cursor left the snippet region.
|
||||||
@ -292,11 +297,6 @@ local function setup_autocmds(bufnr)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Just update the tabstop in insert and select modes.
|
|
||||||
if not vim.fn.mode():match('^[isS]') then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Update the current tabstop to be the one containing the cursor.
|
-- Update the current tabstop to be the one containing the cursor.
|
||||||
for tabstop_index, tabstops in pairs(M._session.tabstops) do
|
for tabstop_index, tabstops in pairs(M._session.tabstops) do
|
||||||
for _, tabstop in ipairs(tabstops) do
|
for _, tabstop in ipairs(tabstops) do
|
||||||
|
@ -165,10 +165,10 @@ describe('vim.snippet', function()
|
|||||||
eq(false, exec_lua('return vim.snippet.active()'))
|
eq(false, exec_lua('return vim.snippet.active()'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('cancels session when leaving snippet region', function()
|
it('cancels session when inserting outside snippet region', function()
|
||||||
feed('i<cr>')
|
feed('i<cr>')
|
||||||
test_success({ 'local function $1()', ' $0', 'end' }, { '', 'local function ()', ' ', 'end' })
|
test_success({ 'local function $1()', ' $0', 'end' }, { '', 'local function ()', ' ', 'end' })
|
||||||
feed('<esc>k')
|
feed('<esc>O-- A comment')
|
||||||
eq(false, exec_lua('return vim.snippet.active()'))
|
eq(false, exec_lua('return vim.snippet.active()'))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user