diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2023-11-30 20:35:25 +0000 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2023-11-30 20:35:25 +0000 |
commit | 1b7b916b7631ddf73c38e3a0070d64e4636cb2f3 (patch) | |
tree | cd08258054db80bb9a11b1061bb091c70b76926a /test/functional/ui/inccommand_user_spec.lua | |
parent | eaa89c11d0f8aefbb512de769c6c82f61a8baca3 (diff) | |
parent | 4a8bf24ac690004aedf5540fa440e788459e5e34 (diff) | |
download | rneovim-aucmd_textputpost.tar.gz rneovim-aucmd_textputpost.tar.bz2 rneovim-aucmd_textputpost.zip |
Merge remote-tracking branch 'upstream/master' into aucmd_textputpostaucmd_textputpost
Diffstat (limited to 'test/functional/ui/inccommand_user_spec.lua')
-rw-r--r-- | test/functional/ui/inccommand_user_spec.lua | 146 |
1 files changed, 144 insertions, 2 deletions
diff --git a/test/functional/ui/inccommand_user_spec.lua b/test/functional/ui/inccommand_user_spec.lua index 43e9b94feb..da7508fad1 100644 --- a/test/functional/ui/inccommand_user_spec.lua +++ b/test/functional/ui/inccommand_user_spec.lua @@ -239,7 +239,8 @@ describe("'inccommand' for user commands", function() [1] = {background = Screen.colors.Yellow1}, [2] = {foreground = Screen.colors.Blue1, bold = true}, [3] = {reverse = true}, - [4] = {reverse = true, bold = true} + [4] = {reverse = true, bold = true}, + [5] = {foreground = Screen.colors.Blue}, }) screen:attach() exec_lua(setup_replace_cmd) @@ -391,7 +392,7 @@ describe("'inccommand' for user commands", function() vim.api.nvim_create_user_command('Replace', function() end, { nargs = '*', preview = function() - vim.api.nvim_set_option('inccommand', 'split') + vim.api.nvim_set_option_value('inccommand', 'split', {}) return 2 end, }) @@ -401,6 +402,147 @@ describe("'inccommand' for user commands", function() feed('e') assert_alive() end) + + it('no crash when adding highlight after :substitute #21495', function() + command('set inccommand=nosplit') + exec_lua([[ + vim.api.nvim_create_user_command("Crash", function() end, { + preview = function(_, preview_ns, _) + vim.cmd("%s/text/cats/g") + vim.api.nvim_buf_add_highlight(0, preview_ns, "Search", 0, 0, -1) + return 1 + end, + }) + ]]) + feed(':C') + screen:expect([[ + {1: cats on line 1} | + more cats on line 2 | + oh no, even more cats | + will the cats ever stop | + oh well | + did the cats stop | + why won't it stop | + make the cats stop | + | + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + :C^ | + ]]) + assert_alive() + end) + + it('no crash if preview callback executes undo #20036', function() + command('set inccommand=nosplit') + exec_lua([[ + vim.api.nvim_create_user_command('Foo', function() end, { + nargs = '?', + preview = function(_, _, _) + vim.cmd.undo() + end, + }) + ]]) + + -- Clear undo history + command('set undolevels=-1') + feed('ggyyp') + command('set undolevels=1000') + + feed('yypp:Fo') + assert_alive() + feed('<Esc>:Fo') + assert_alive() + end) + + local function test_preview_break_undo() + command('set inccommand=nosplit') + exec_lua([[ + vim.api.nvim_create_user_command('Test', function() end, { + nargs = 1, + preview = function(opts, _, _) + vim.cmd('norm i' .. opts.args) + return 1 + end + }) + ]]) + feed(':Test a.a.a.a.') + screen:expect([[ + text on line 1 | + more text on line 2 | + oh no, even more text | + will the text ever stop | + oh well | + did the text stop | + why won't it stop | + make the text stop | + a.a.a.a. | + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + :Test a.a.a.a.^ | + ]]) + feed('<C-V><Esc>u') + screen:expect([[ + text on line 1 | + more text on line 2 | + oh no, even more text | + will the text ever stop | + oh well | + did the text stop | + why won't it stop | + make the text stop | + a.a.a. | + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + :Test a.a.a.a.{5:^[}u^ | + ]]) + feed('<Esc>') + screen:expect([[ + text on line 1 | + more text on line 2 | + oh no, even more text | + will the text ever stop | + oh well | + did the text stop | + why won't it stop | + make the text stop | + ^ | + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + {2:~ }| + | + ]]) + end + + describe('breaking undo chain in Insert mode works properly', function() + it('when using i_CTRL-G_u #20248', function() + command('inoremap . .<C-G>u') + test_preview_break_undo() + end) + + it('when setting &l:undolevels to itself #24575', function() + command('inoremap . .<Cmd>let &l:undolevels = &l:undolevels<CR>') + test_preview_break_undo() + end) + end) end) describe("'inccommand' with multiple buffers", function() |