fix(client): VimwikiColorize accepts a range (no more E481 on selection)
Selecting text and running :VimwikiColorize {color} raised
"E481: No range allowed" — Vim prepends '<,'> to the command when invoked
from a visual selection, but the command was defined without -range.
All four colorize command defs (Vim + Neovim, Vimwiki* + Nuwiki*) are now
-range and forward the range count to the handler. A ranged (visual)
invocation wraps the '< / '> selection; a bare invocation wraps the cword.
The x-mode <Leader>wc mapping passes the visual flag explicitly.
The Vim-branch colorize() gained selection support (it was cword-only),
matching the Neovim branch, so both clients wrap a visual selection
identically. visual_selection_range() (Lua) no longer gates on
vim.fn.visualmode() — the explicit visual flag now carries that intent, and
the marks check guards unset selections.
Tests: cmd.Colorize_range_wraps_selection (nvim) and
colorize.{command_wraps_cword,visual_wraps_selection,ranged_command_no_error}
(vim). nvim 268, vim 257+18, all green.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -761,6 +761,18 @@ vim.defer_fn(function()
|
||||
error('visual colorize did not wrap selection: ' .. got)
|
||||
end
|
||||
end)
|
||||
-- Invoking the command with a range (`:'<,'>VimwikiColorize`, as Vim builds
|
||||
-- it when you select then type the command) must not error (-range) and
|
||||
-- wraps the selection.
|
||||
tobj_case('cmd.Colorize_range_wraps_selection', function()
|
||||
set_buf({ 'pick this word' })
|
||||
vim.cmd('normal! 0wviw\27') -- select 'this'
|
||||
vim.cmd("'<,'>VimwikiColorize orange")
|
||||
local got = vim.api.nvim_get_current_line()
|
||||
if got ~= 'pick <span style="color:orange">this</span> word' then
|
||||
error('ranged command did not wrap selection: ' .. got)
|
||||
end
|
||||
end)
|
||||
|
||||
-- ===== Wiki picker (config-driven, no LSP) =====
|
||||
-- The picker must build its list from config so it works from any buffer
|
||||
|
||||
Reference in New Issue
Block a user