commit 0fdf59ac9d30d8874ba6eba22a8bdfb41c1603b7
parent 0df1418ffab4e9e514422b7074386519fb0d28b2
Author: Lewis Russell <lewis6991@gmail.com>
Date: Sat, 6 Aug 2022 13:53:37 +0100
fix(api): nvim_cmd handle 0 range (#19655)
Fixes #19608
Diffstat:
2 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
@@ -1693,6 +1693,8 @@ int execute_cmd(exarg_T *eap, CmdParseInfo *cmdinfo, bool preview)
ERROR(_(e_cannot_edit_other_buf));
}
+ correct_range(eap);
+
if (((eap->argt & EX_WHOLEFOLD) || eap->addr_count >= 2) && !global_busy
&& eap->addr_type == ADDR_LINES) {
// Put the first line at the start of a closed fold, put the last line
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
@@ -3822,5 +3822,12 @@ describe('API', function()
feed("[l")
neq(nil, string.find(eval("v:errmsg"), "E5108:"))
end)
+ it('handles 0 range #19608', function()
+ meths.buf_set_lines(0, 0, -1, false, { "aa" })
+ meths.cmd({ cmd = 'delete', range = { 0 } }, {})
+ command('undo')
+ eq({'aa'}, meths.buf_get_lines(0, 0, 1, false))
+ assert_alive()
+ end)
end)
end)