diff --git a/runtime/lua/vim/treesitter/_range.lua b/runtime/lua/vim/treesitter/_range.lua index 3f1238d036..e6ee89d19e 100644 --- a/runtime/lua/vim/treesitter/_range.lua +++ b/runtime/lua/vim/treesitter/_range.lua @@ -194,6 +194,10 @@ function M.visual_select(range) cursor_other_end_of_selection = true end + if vim.o.selection == 'exclusive' then + end_col = end_col + 1 + end + vim.fn.setpos("'<", { 0, start_row + 1, start_col + 1, 0 }) vim.fn.setpos("'>", { 0, end_row + 1, end_col, 0 }) diff --git a/runtime/lua/vim/treesitter/_select.lua b/runtime/lua/vim/treesitter/_select.lua index 0765ae3b16..e77e51a0c5 100644 --- a/runtime/lua/vim/treesitter/_select.lua +++ b/runtime/lua/vim/treesitter/_select.lua @@ -357,6 +357,10 @@ local function get_selection() pos1, pos2 = pos2, pos1 end + if vim.o.selection == 'exclusive' then + pos2[3] = pos2[3] - 1 + end + if pos2[3] == #vim.fn.getline(pos2[2]) + 1 then pos2[2] = pos2[2] + 1 pos2[3] = 0