diff options
| author | Santos Gallegos <stsewd@protonmail.com> | 2021-12-19 20:25:12 -0500 |
|---|---|---|
| committer | Stephan Seitz <stephan.seitz@fau.de> | 2021-12-20 15:12:12 +0100 |
| commit | 1f303c7f3c93b0a9066c1297a2a4b63e4b545f2b (patch) | |
| tree | 69e52f4cf0572652a3e0c52394977b1208225a67 /lua | |
| parent | Update lockfile.json (diff) | |
| download | nvim-treesitter-1f303c7f3c93b0a9066c1297a2a4b63e4b545f2b.tar nvim-treesitter-1f303c7f3c93b0a9066c1297a2a4b63e4b545f2b.tar.gz nvim-treesitter-1f303c7f3c93b0a9066c1297a2a4b63e4b545f2b.tar.bz2 nvim-treesitter-1f303c7f3c93b0a9066c1297a2a4b63e4b545f2b.tar.lz nvim-treesitter-1f303c7f3c93b0a9066c1297a2a4b63e4b545f2b.tar.xz nvim-treesitter-1f303c7f3c93b0a9066c1297a2a4b63e4b545f2b.tar.zst nvim-treesitter-1f303c7f3c93b0a9066c1297a2a4b63e4b545f2b.zip | |
goto_node: normalize range for nvim_win_set_cursor
Looks like neovim doesn't accept -1 on nvim_win_set_cursor.
It's listed as an exception on `:h api-indexing`.
Fixes https://github.com/nvim-treesitter/nvim-treesitter-textobjects/issues/149
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/nvim-treesitter/ts_utils.lua | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/lua/nvim-treesitter/ts_utils.lua b/lua/nvim-treesitter/ts_utils.lua index 4df84e3ba..1a5323e45 100644 --- a/lua/nvim-treesitter/ts_utils.lua +++ b/lua/nvim-treesitter/ts_utils.lua @@ -374,19 +374,15 @@ function M.goto_node(node, goto_end, avoid_set_jump) if not avoid_set_jump then utils.set_jump() end - local range = { node:range() } + local range = { M.get_vim_range { node:range() } } local position if not goto_end then position = { range[1], range[2] } else - -- ranges are exclusive: -1 character! - if range[4] == 0 then - position = { range[3] - 1, -1 } - else - position = { range[3], range[4] - 1 } - end + position = { range[3], range[4] } end - api.nvim_win_set_cursor(0, { position[1] + 1, position[2] }) + -- Position is 1, 0 indexed. + api.nvim_win_set_cursor(0, { position[1], position[2] - 1 }) end return M |
