aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/nvim-treesitter/ts_utils.lua8
1 files changed, 8 insertions, 0 deletions
diff --git a/lua/nvim-treesitter/ts_utils.lua b/lua/nvim-treesitter/ts_utils.lua
index f0cccc2cc..373bae340 100644
--- a/lua/nvim-treesitter/ts_utils.lua
+++ b/lua/nvim-treesitter/ts_utils.lua
@@ -452,6 +452,14 @@ function M.goto_node(node, goto_end, avoid_set_jump)
else
position = { range[3], range[4] }
end
+
+ -- Enter visual mode if we are in operator pending mode
+ -- If we don't do this, it will miss the last character.
+ local mode = vim.api.nvim_get_mode()
+ if mode.mode == "no" then
+ vim.cmd "normal! v"
+ end
+
-- Position is 1, 0 indexed.
api.nvim_win_set_cursor(0, { position[1], position[2] - 1 })
end