Skip to content

Conversation

@Dook97
Copy link

@Dook97 Dook97 commented Dec 20, 2025

I "fixed" an issue in #840 only to realize, I left it broken in another way. Sorry for that. Anyway, here's the actual fix (I hope).

I frankly still don't understand, why end_col = end_col - 1 is needed in the first place, as it breaks the expected behaviour of is_in_range(). I assume it's a quirk specific to the location where the function was being called from, so I moved it there.

@kiyoon
Copy link
Collaborator

kiyoon commented Dec 21, 2025

Because treesitter range is end-exclusive. For example there are cases like (last_row+1, 0) is the end position to mean it's till the end of the file. If you don't calibrate it well, it will throw out of range error.

I think the safest fix is to copy the functions from neovim upstream for now.

contains()

https://github.com/neovim/neovim/blob/81e2d2ea53479da1b7b147ab17a72d25babf6b8e/runtime/lua/vim/treesitter/_range.lua#L142-L160

is_in_range()

https://github.com/neovim/neovim/blob/81e2d2ea53479da1b7b147ab17a72d25babf6b8e/runtime/lua/vim/treesitter.lua#L250-L259

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants