diff --git a/src/nvim/api/command.c b/src/nvim/api/command.c index 4ea40a330b..325de4c53d 100644 --- a/src/nvim/api/command.c +++ b/src/nvim/api/command.c @@ -1170,6 +1170,7 @@ void create_user_command(uint64_t channel_id, String name, Union(String, LuaRef) goto err; }); + argt |= EX_RANGE; if (addr_type_arg != ADDR_LINES) { argt |= EX_ZEROR; } diff --git a/test/functional/api/command_spec.lua b/test/functional/api/command_spec.lua index cc09178834..2d49febf57 100644 --- a/test/functional/api/command_spec.lua +++ b/test/functional/api/command_spec.lua @@ -782,6 +782,13 @@ describe('nvim_create_user_command', function() eq(5, #api.nvim_list_tabpages()) eq(1, fn.tabpagenr()) end) + + it('"addr" flag allows ranges without explicit "range" flag', function() + exec_lua([[ + vim.api.nvim_create_user_command('Test2', 'echo "hello "', { addr = 'other' }) + ]]) + eq('hello 12', n.exec_capture('1,2Test2')) + end) end) describe('nvim_del_user_command', function()