File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
lua/nvim-treesitter-textobjects Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -20,16 +20,23 @@ local function update_selection(range, selection_mode)
2020 vim .cmd .normal ({ selection_mode , bang = true })
2121 end
2222
23- local end_col_offset = 1
23+ -- end positions with `col=0` mean "up to the end of the previous line, including the newline character"
24+ if end_col == 0 then
25+ end_row = end_row - 1
26+ -- +1 is needed because we are interpreting `end_col` to be exclusive afterwards
27+ end_col = # api .nvim_buf_get_lines (0 , end_row , end_row + 1 , true )[1 ] + 1
28+ end
2429
30+ local end_col_offset = 1
2531 if selection_mode == ' v' and vim .o .selection == ' exclusive' then
2632 end_col_offset = 0
2733 end
34+ end_col = end_col - end_col_offset
2835
2936 -- Position is 1, 0 indexed.
3037 api .nvim_win_set_cursor (0 , { start_row + 1 , start_col })
3138 vim .cmd (' normal! o' )
32- api .nvim_win_set_cursor (0 , { end_row + 1 , end_col - end_col_offset })
39+ api .nvim_win_set_cursor (0 , { end_row + 1 , end_col })
3340end
3441
3542local M = {}
You can’t perform that action at this time.
0 commit comments