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:
@@ -103,7 +103,7 @@ if !has('nvim')
|
||||
command! -buffer -nargs=1 VimwikiTable call nuwiki#commands#table_insert()
|
||||
command! -buffer VimwikiTableMoveColumnLeft call nuwiki#commands#table_move_left()
|
||||
command! -buffer VimwikiTableMoveColumnRight call nuwiki#commands#table_move_right()
|
||||
command! -buffer -nargs=1 VimwikiColorize call nuwiki#commands#colorize(<q-args>)
|
||||
command! -buffer -nargs=1 -range VimwikiColorize call nuwiki#commands#colorize(<q-args>, <range>)
|
||||
command! -buffer VimwikiPasteLink call nuwiki#commands#paste_link()
|
||||
command! -buffer VimwikiPasteUrl call nuwiki#commands#paste_url()
|
||||
command! -buffer VimwikiCatUrl call nuwiki#commands#cat_url()
|
||||
@@ -174,7 +174,7 @@ if !has('nvim')
|
||||
command! -buffer -nargs=1 NuwikiTable call nuwiki#commands#table_insert()
|
||||
command! -buffer NuwikiTableMoveColumnLeft call nuwiki#commands#table_move_left()
|
||||
command! -buffer NuwikiTableMoveColumnRight call nuwiki#commands#table_move_right()
|
||||
command! -buffer -nargs=1 NuwikiColorize call nuwiki#commands#colorize(<q-args>)
|
||||
command! -buffer -nargs=1 -range NuwikiColorize call nuwiki#commands#colorize(<q-args>, <range>)
|
||||
command! -buffer NuwikiPasteLink call nuwiki#commands#paste_link()
|
||||
command! -buffer NuwikiPasteUrl call nuwiki#commands#paste_url()
|
||||
command! -buffer NuwikiCatUrl call nuwiki#commands#cat_url()
|
||||
@@ -216,7 +216,7 @@ if !has('nvim')
|
||||
nnoremap <silent><buffer> <Leader>wd :call nuwiki#commands#delete_file()<CR>
|
||||
nnoremap <silent><buffer> <Leader>wr :call nuwiki#commands#rename_file()<CR>
|
||||
nnoremap <silent><buffer> <Leader>wc :call nuwiki#commands#colorize('')<CR>
|
||||
xnoremap <silent><buffer> <Leader>wc :<C-u>call nuwiki#commands#colorize('')<CR>
|
||||
xnoremap <silent><buffer> <Leader>wc :<C-u>call nuwiki#commands#colorize('', 2)<CR>
|
||||
endif
|
||||
|
||||
" Diary nav
|
||||
@@ -442,7 +442,7 @@ command! -buffer -nargs=? VimwikiGenerateTags lua require('nuwiki.commands'
|
||||
command! -buffer -nargs=1 VimwikiTable lua require('nuwiki.commands').table_insert()
|
||||
command! -buffer VimwikiTableMoveColumnLeft lua require('nuwiki.commands').table_move_column_left()
|
||||
command! -buffer VimwikiTableMoveColumnRight lua require('nuwiki.commands').table_move_column_right()
|
||||
command! -buffer -nargs=1 VimwikiColorize lua require('nuwiki.commands').colorize(<q-args>)
|
||||
command! -buffer -nargs=1 -range VimwikiColorize lua require('nuwiki.commands').colorize(<q-args>, <range> > 0)
|
||||
command! -buffer VimwikiPasteLink lua require('nuwiki.commands').paste_link()
|
||||
command! -buffer VimwikiPasteUrl lua require('nuwiki.commands').paste_url()
|
||||
command! -buffer VimwikiCatUrl lua require('nuwiki.commands').cat_url()
|
||||
@@ -514,7 +514,7 @@ command! -buffer NuwikiTableAlign lua require('nuwiki.command
|
||||
command! -buffer -nargs=1 NuwikiTable lua require('nuwiki.commands').table_insert()
|
||||
command! -buffer NuwikiTableMoveColumnLeft lua require('nuwiki.commands').table_move_column_left()
|
||||
command! -buffer NuwikiTableMoveColumnRight lua require('nuwiki.commands').table_move_column_right()
|
||||
command! -buffer -nargs=1 NuwikiColorize lua require('nuwiki.commands').colorize(<q-args>)
|
||||
command! -buffer -nargs=1 -range NuwikiColorize lua require('nuwiki.commands').colorize(<q-args>, <range> > 0)
|
||||
command! -buffer NuwikiPasteLink lua require('nuwiki.commands').paste_link()
|
||||
command! -buffer NuwikiPasteUrl lua require('nuwiki.commands').paste_url()
|
||||
command! -buffer NuwikiCatUrl lua require('nuwiki.commands').cat_url()
|
||||
|
||||
Reference in New Issue
Block a user