mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-21 12:50:09 -04:00
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
```
This commit is contained in:
parent
a0abaf936c
commit
5742cf1d12
1 changed files with 3 additions and 0 deletions
|
|
@ -17,6 +17,9 @@ function M.goto_definition(bufnr)
|
||||||
if not node_at_point then return end
|
if not node_at_point then return end
|
||||||
|
|
||||||
local definition, _ = locals.find_definition(node_at_point, bufnr)
|
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()
|
local start_row, start_col, _ = definition:start()
|
||||||
|
|
||||||
api.nvim_win_set_cursor(0, { start_row + 1, start_col })
|
api.nvim_win_set_cursor(0, { start_row + 1, start_col })
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue