Skip to content

Commit

Permalink
Adjust selected range if set selection? is exclusive
Browse files Browse the repository at this point in the history
  • Loading branch information
afgomez committed Sep 8, 2024
1 parent a34d063 commit 9465c2c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lua/nvim-treesitter-textobjects/select.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,16 @@ local function update_selection(range, selection_mode)
vim.cmd.normal { selection_mode, bang = true }
end

local end_col_offset = 1

if selection_mode == "v" and vim.o.selection == "exclusive" then
end_col_offset = 0
end

-- Position is 1, 0 indexed.
api.nvim_win_set_cursor(0, { start_row + 1, start_col })
vim.cmd "normal! o"
api.nvim_win_set_cursor(0, { end_row + 1, end_col - 1 })
api.nvim_win_set_cursor(0, { end_row + 1, end_col - end_col_offset })
end

local M = {}
Expand Down

0 comments on commit 9465c2c

Please sign in to comment.