diff options
| author | glepnir <glephunter@gmail.com> | 2025-08-03 10:52:54 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-02 19:52:54 -0700 |
| commit | 22df6492101f0163c0126dcdf2be01bd58ae7c28 (patch) | |
| tree | d4f5a243edcd66850e567b0558b698c2874cc40b /test/functional/api/command_spec.lua | |
| parent | 93f5bd0caf9037f95ee77288bfd424008bc3a14b (diff) | |
| download | rneovim-22df6492101f0163c0126dcdf2be01bd58ae7c28.tar.gz rneovim-22df6492101f0163c0126dcdf2be01bd58ae7c28.tar.bz2 rneovim-22df6492101f0163c0126dcdf2be01bd58ae7c28.zip | |
fix(api): nvim_create_user_command addr option should allow ranges #35077
Problem: Using `addr` without `range` in nvim_create_user_command gives
"No range allowed" error, inconsistent with `:command -addr` behavior.
Solution: Set EX_RANGE flag when `addr` option is specified to match
`:command` behavior.
Diffstat (limited to 'test/functional/api/command_spec.lua')
| -rw-r--r-- | test/functional/api/command_spec.lua | 7 |
1 files changed, 7 insertions, 0 deletions
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 <line1><line2>"', { addr = 'other' }) + ]]) + eq('hello 12', n.exec_capture('1,2Test2')) + end) end) describe('nvim_del_user_command', function() |