From 57a296d899d170e7f78aec2225bf8ab2b0dc711c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 2 Jun 2022 03:48:36 +0800 Subject: fix(inccommand): avoid crash if callback changes inccommand option (#18830) clang: Result of operation is garbage or undefined clang: Uninitialized argument value Also check for == 's' instead of != 'n' as it is more straightforward. Also fix another unrelated PVS warning: PVS/V1071: Return value of win_comp_pos() is not always used --- test/functional/ui/inccommand_user_spec.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test/functional') diff --git a/test/functional/ui/inccommand_user_spec.lua b/test/functional/ui/inccommand_user_spec.lua index 6c54ede582..b5816f6fe6 100644 --- a/test/functional/ui/inccommand_user_spec.lua +++ b/test/functional/ui/inccommand_user_spec.lua @@ -336,4 +336,21 @@ describe("'inccommand' for user commands", function() feed('e') assert_alive() end) + + it('no crash if preview callback changes inccommand option', function() + command('set inccommand=nosplit') + exec_lua([[ + vim.api.nvim_create_user_command('Replace', function() end, { + nargs = '*', + preview = function() + vim.api.nvim_set_option('inccommand', 'split') + return 2 + end, + }) + ]]) + feed(':R') + assert_alive() + feed('e') + assert_alive() + end) end) -- cgit