mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-03 03:56:52 -04:00
feat(ts_utils): allow starting selection after last character (#3233)
This commit is contained in:
parent
5c4548c070
commit
0d7fab0c33
2 changed files with 69 additions and 2 deletions
|
|
@ -259,14 +259,14 @@ 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_vim_range({ M.get_node_range(node) }, buf)
|
||||
|
||||
vim.fn.setpos(".", { buf, start_row, start_col, 0 })
|
||||
|
||||
-- Start visual selection in appropriate 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 mode_string = vim.api.nvim_replace_termcodes(v_table[selection_mode] or selection_mode, true, true, true)
|
||||
vim.cmd("normal! " .. mode_string)
|
||||
vim.fn.setpos(".", { buf, start_row, start_col, 0 })
|
||||
vim.cmd "normal! o"
|
||||
vim.fn.setpos(".", { buf, end_row, end_col, 0 })
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue