diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-08-22 18:06:18 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-22 18:06:18 +0800 |
commit | 15a768eeb02e2af39eead1ea1eb4a5a60710d6fb (patch) | |
tree | 2bd35938536d2d4a30ef993b5d8ab53f851c22df /test/functional/api/vim_spec.lua | |
parent | 2bed0d1d978b42184564201088ea5fef12ec8581 (diff) | |
download | rneovim-15a768eeb02e2af39eead1ea1eb4a5a60710d6fb.tar.gz rneovim-15a768eeb02e2af39eead1ea1eb4a5a60710d6fb.tar.bz2 rneovim-15a768eeb02e2af39eead1ea1eb4a5a60710d6fb.zip |
fix(api): avoid side effects with nvim_parse_cmd (#19890)
Save and restore the cursor and last search pattern and do not change
search history.
Diffstat (limited to 'test/functional/api/vim_spec.lua')
-rw-r--r-- | test/functional/api/vim_spec.lua | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 72a03c409a..24d0b6da45 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -3668,6 +3668,55 @@ describe('API', function() :^ | ]]) end) + it('does not move cursor or change search history/pattern #19878 #19890', function() + meths.buf_set_lines(0, 0, -1, true, {'foo', 'bar', 'foo', 'bar'}) + eq({1, 0}, meths.win_get_cursor(0)) + eq('', funcs.getreg('/')) + eq('', funcs.histget('search')) + feed(':') -- call the API in cmdline mode to test whether it changes search history + eq({ + cmd = 'normal', + args = {'x'}, + bang = true, + range = {3, 4}, + count = -1, + reg = '', + addr = 'line', + magic = { + file = false, + bar = false, + }, + nargs = '+', + nextcmd = '', + mods = { + browse = false, + confirm = false, + emsg_silent = false, + filter = { + pattern = "", + force = false, + }, + hide = false, + keepalt = false, + keepjumps = false, + keepmarks = false, + keeppatterns = false, + lockmarks = false, + noautocmd = false, + noswapfile = false, + sandbox = false, + silent = false, + split = "", + tab = 0, + unsilent = false, + verbose = -1, + vertical = false, + } + }, meths.parse_cmd('+2;/bar/normal! x', {})) + eq({1, 0}, meths.win_get_cursor(0)) + eq('', funcs.getreg('/')) + eq('', funcs.histget('search')) + end) end) describe('nvim_cmd', function() it('works', function () |