From 5742cf1d123b8f203d2b7180807371d610323720 Mon Sep 17 00:00:00 2001 From: Santos Gallegos Date: Mon, 3 Aug 2020 20:28:08 -0500 Subject: [PATCH] Goto: don't move the cursor if already on the node For example, executing a goto over ba[r] will move the cursor to [b]ar. ```python def foo(bar): pass ``` --- lua/nvim-treesitter/refactor/navigation.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/nvim-treesitter/refactor/navigation.lua b/lua/nvim-treesitter/refactor/navigation.lua index 160fbd2e3..b1467c65d 100644 --- a/lua/nvim-treesitter/refactor/navigation.lua +++ b/lua/nvim-treesitter/refactor/navigation.lua @@ -17,6 +17,9 @@ function M.goto_definition(bufnr) if not node_at_point then return end local definition, _ = locals.find_definition(node_at_point, bufnr) + -- Don't move the cursor if we are already there + if definition == node_at_point then return end + local start_row, start_col, _ = definition:start() api.nvim_win_set_cursor(0, { start_row + 1, start_col })