diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-06-02 03:48:36 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-02 03:48:36 +0800 |
commit | 57a296d899d170e7f78aec2225bf8ab2b0dc711c (patch) | |
tree | 082a19f7f7df82b489106af2620385b88887c092 /test/functional/ui/inccommand_user_spec.lua | |
parent | 209824ce2c6d37332079e6e213d4b8e257d7d53b (diff) | |
download | rneovim-57a296d899d170e7f78aec2225bf8ab2b0dc711c.tar.gz rneovim-57a296d899d170e7f78aec2225bf8ab2b0dc711c.tar.bz2 rneovim-57a296d899d170e7f78aec2225bf8ab2b0dc711c.zip |
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
Diffstat (limited to 'test/functional/ui/inccommand_user_spec.lua')
-rw-r--r-- | test/functional/ui/inccommand_user_spec.lua | 17 |
1 files changed, 17 insertions, 0 deletions
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) |