diff options
author | Maria José Solano <majosolano99@gmail.com> | 2023-10-25 22:29:05 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-26 07:29:05 +0200 |
commit | 15983cf2c64c527fc13681925d0d00c070c30640 (patch) | |
tree | 83430e425fc9bbac5e36dd396909cde85822330d /runtime/lua/vim/snippet.lua | |
parent | 9de157bce4b6eb055a0d7a39d1ed6b7a6e6c6545 (diff) | |
download | rneovim-15983cf2c64c527fc13681925d0d00c070c30640.tar.gz rneovim-15983cf2c64c527fc13681925d0d00c070c30640.tar.bz2 rneovim-15983cf2c64c527fc13681925d0d00c070c30640.zip |
fix(lsp): cancel session when leaving snippet region (#25762)
Diffstat (limited to 'runtime/lua/vim/snippet.lua')
-rw-r--r-- | runtime/lua/vim/snippet.lua | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/runtime/lua/vim/snippet.lua b/runtime/lua/vim/snippet.lua index 7680d2e216..14f73bff5c 100644 --- a/runtime/lua/vim/snippet.lua +++ b/runtime/lua/vim/snippet.lua @@ -278,13 +278,26 @@ local function setup_autocmds(bufnr) desc = 'Update snippet state when the cursor moves', buffer = bufnr, callback = function() + local cursor_row, cursor_col = cursor_pos() + + -- The cursor left the snippet region. + local snippet_range = get_extmark_range(bufnr, M._session.extmark_id) + if + cursor_row < snippet_range[1] + or (cursor_row == snippet_range[1] and cursor_col < snippet_range[2]) + or cursor_row > snippet_range[3] + or (cursor_row == snippet_range[3] and cursor_col > snippet_range[4]) + then + M.exit() + 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. - local cursor_row, cursor_col = cursor_pos() for tabstop_index, tabstops in pairs(M._session.tabstops) do for _, tabstop in ipairs(tabstops) do local range = tabstop:get_range() |