diff options
author | Maria José Solano <majosolano99@gmail.com> | 2023-10-30 04:58:28 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-30 12:58:28 +0100 |
commit | 0fe0cf5adaab06b92250eb350306de63c4d4f36f (patch) | |
tree | 446b4ed8c0bff6331e9bde1c16a17edecaabe8ad | |
parent | 8405649f92a8a8eb254944eca15e8b0169cbb6fb (diff) | |
download | rneovim-0fe0cf5adaab06b92250eb350306de63c4d4f36f.tar.gz rneovim-0fe0cf5adaab06b92250eb350306de63c4d4f36f.tar.bz2 rneovim-0fe0cf5adaab06b92250eb350306de63c4d4f36f.zip |
fix(lsp): do not cancel snippet when selecting placeholder (#25835)
-rw-r--r-- | runtime/lua/vim/snippet.lua | 10 | ||||
-rw-r--r-- | test/functional/lua/snippet_spec.lua | 4 |
2 files changed, 7 insertions, 7 deletions
diff --git a/runtime/lua/vim/snippet.lua b/runtime/lua/vim/snippet.lua index 14f73bff5c..94c69795a4 100644 --- a/runtime/lua/vim/snippet.lua +++ b/runtime/lua/vim/snippet.lua @@ -278,6 +278,11 @@ local function setup_autocmds(bufnr) desc = 'Update snippet state when the cursor moves', buffer = bufnr, 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() -- The cursor left the snippet region. @@ -292,11 +297,6 @@ local function setup_autocmds(bufnr) return true 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. for tabstop_index, tabstops in pairs(M._session.tabstops) do for _, tabstop in ipairs(tabstops) do diff --git a/test/functional/lua/snippet_spec.lua b/test/functional/lua/snippet_spec.lua index 390f268925..70337d1572 100644 --- a/test/functional/lua/snippet_spec.lua +++ b/test/functional/lua/snippet_spec.lua @@ -165,10 +165,10 @@ describe('vim.snippet', function() eq(false, exec_lua('return vim.snippet.active()')) end) - it('cancels session when leaving snippet region', function() + it('cancels session when inserting outside snippet region', function() feed('i<cr>') 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()')) end) end) |