From 8695579636b4f76561f54b92aac1a05ca00d09a1 Mon Sep 17 00:00:00 2001 From: altermo <107814000+altermo@users.noreply.github.com> Date: Sat, 1 Aug 2026 18:13:21 +0200 Subject: [PATCH] fix(treesitter): handle `&selection=exclusive` --- runtime/lua/vim/treesitter/_range.lua | 4 ++++ runtime/lua/vim/treesitter/_select.lua | 4 ++++ 2 files changed, 8 insertions(+) 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