mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-02 03:26:52 -04:00
Add "v", "V", "<C-v>" as valid options of selection_mode.
This commit is contained in:
parent
a34459213e
commit
079dafa36e
1 changed files with 5 additions and 4 deletions
|
|
@ -131,7 +131,8 @@ function M.highlight_range(range, buf, hl_namespace, hl_group)
|
|||
end
|
||||
|
||||
-- Set visual selection to node
|
||||
-- @param selection_mode One of "charwise" (default), "linewise", "blockwise"
|
||||
-- @param selection_mode One of "charwise" (default) or "v", "linewise" or "V",
|
||||
-- "blockwise" or "<C-v>" (as a string with 5 characters or a single character)
|
||||
function M.update_selection(buf, node, selection_mode)
|
||||
selection_mode = selection_mode or "charwise"
|
||||
local start_row, start_col, end_row, end_col = M.get_node_range(node)
|
||||
|
|
@ -152,10 +153,10 @@ function M.update_selection(buf, node, selection_mode)
|
|||
local v_table = {charwise = "v", linewise = "V", blockwise = "<C-v>"}
|
||||
---- Call to `nvim_replace_termcodes()` is needed for sending appropriate
|
||||
---- command to enter blockwise mode
|
||||
local command = vim.api.nvim_replace_termcodes(
|
||||
"normal! " .. v_table[selection_mode], true, true, true
|
||||
local mode_string = vim.api.nvim_replace_termcodes(
|
||||
v_table[selection_mode] or selection_mode, true, true, true
|
||||
)
|
||||
vim.cmd(command)
|
||||
vim.cmd("normal! " .. mode_string)
|
||||
|
||||
-- Convert exclusive end position to inclusive
|
||||
if end_col == 1 then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue