diff options
author | Gregory Anders <8965202+gpanders@users.noreply.github.com> | 2024-05-28 12:39:30 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-28 12:39:30 -0500 |
commit | 0bdd602bf974fdefc348f47bb7b9057521eb0407 (patch) | |
tree | 5bec46754be4714b72e10a8ebe295d9606d0d59d /test/functional/lua/snippet_spec.lua | |
parent | 8ba73f0e4cc6c82032a348a1d6c8d794ed150fd7 (diff) | |
parent | e6cfcaed184d4ecdc8a8638429e1bd9e1b3251dc (diff) | |
download | rneovim-0bdd602bf974fdefc348f47bb7b9057521eb0407.tar.gz rneovim-0bdd602bf974fdefc348f47bb7b9057521eb0407.tar.bz2 rneovim-0bdd602bf974fdefc348f47bb7b9057521eb0407.zip |
Merge pull request #27339 from MariaSolOs/completion
feat(lsp): completion side effects
Diffstat (limited to 'test/functional/lua/snippet_spec.lua')
-rw-r--r-- | test/functional/lua/snippet_spec.lua | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/test/functional/lua/snippet_spec.lua b/test/functional/lua/snippet_spec.lua index 413aa93994..bca0a59cb4 100644 --- a/test/functional/lua/snippet_spec.lua +++ b/test/functional/lua/snippet_spec.lua @@ -1,3 +1,5 @@ +---@diagnostic disable: no-unknown + local t = require('test.testutil') local n = require('test.functional.testnvim')() @@ -16,11 +18,6 @@ local retry = t.retry describe('vim.snippet', function() before_each(function() clear() - - exec_lua([[ - vim.keymap.set({ 'i', 's' }, '<Tab>', function() vim.snippet.jump(1) end, { buffer = true }) - vim.keymap.set({ 'i', 's' }, '<S-Tab>', function() vim.snippet.jump(-1) end, { buffer = true }) - ]]) end) after_each(clear) @@ -286,4 +283,24 @@ describe('vim.snippet', function() ]] ) end) + + it('restores snippet navigation keymaps', function() + -- Create a buffer keymap in insert mode that deletes all lines. + local curbuf = api.nvim_get_current_buf() + exec_lua('vim.api.nvim_buf_set_keymap(..., "i", "<Tab>", "<cmd>normal ggdG<cr>", {})', curbuf) + + test_expand_success({ 'var $1 = $2' }, { 'var = ' }) + + -- While the snippet is active, <Tab> should navigate between tabstops. + feed('x') + poke_eventloop() + feed('<Tab>0') + eq({ 'var x = 0' }, buf_lines(0)) + + exec_lua('vim.snippet.stop()') + + -- After exiting the snippet, the buffer keymap should be restored. + feed('<Esc>O<cr><Tab>') + eq({ '' }, buf_lines(0)) + end) end) |