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:
Santos Gallegos 2020-08-03 20:28:08 -05:00
parent a0abaf936c
commit 5742cf1d12

View file

@ -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 })