summaryrefslogtreecommitdiff
path: root/lua/nvim-treesitter
diff options
context:
space:
mode:
authorSantos Gallegos <stsewd@protonmail.com>2021-09-18 01:22:02 -0500
committerStephan Seitz <stephan.seitz@fau.de>2021-09-19 14:54:45 +0200
commit3aa122edfd795d1bba1fc3c18c99460c43970c85 (patch)
tree894df5b0b3f59c8f4729358240d560f3d3b5aa22 /lua/nvim-treesitter
parent48215a63f3a6b4d5e9b5a4db7d2548034f321a1b (diff)
Fix incremental selection for nodes that include EOL
From `:h setpos()` > If "col" is smaller than 1 then 1 is used. This can be tested with incremental selection on a vim file. ```vim set title ```
Diffstat (limited to 'lua/nvim-treesitter')
-rw-r--r--lua/nvim-treesitter/ts_utils.lua3
1 files changed, 2 insertions, 1 deletions
diff --git a/lua/nvim-treesitter/ts_utils.lua b/lua/nvim-treesitter/ts_utils.lua
index 72a74edc..11fb17d7 100644
--- a/lua/nvim-treesitter/ts_utils.lua
+++ b/lua/nvim-treesitter/ts_utils.lua
@@ -208,7 +208,8 @@ function M.update_selection(buf, node, selection_mode)
-- Convert exclusive end position to inclusive
if end_col == 1 then
- vim.fn.setpos(".", { buf, end_row - 1, -1, 0 })
+ local previous_col = vim.fn.col { end_row - 1, "$" } - 1
+ vim.fn.setpos(".", { buf, end_row - 1, previous_col, 0 })
else
vim.fn.setpos(".", { buf, end_row, end_col - 1, 0 })
end