You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Introduction:scopes_inrange() compares cursor[1] (1-indexed from nvim_win_get_cursor) against Treesitter node rows (0-indexed from node:range()). The last line of a function scope may be incorrectly excluded from context.
Detailed Description: While the comparison works by accident in some cases, at scope boundaries the off-by-one causes incorrect behavior. For example, if cursor is at line 11 and the scope ends at Treesitter row 10, cursor is correctly within scope but only because the 0-indexed vs 1-indexed offset happens to match. At scope boundaries it fails.
Reproduction:
Open a file with a multi-line function
Place cursor on the last line of the function definition
Context may include or exclude the scope depending on position
One easy fix would be to enforce 1 based indexing in whole program before you start working on it. So you don't have to worry about 0 indexing or 1 indexing.
Activity
[-][Bug][/-][+][Bug] Cursor row off-by-one — Treesitter 0-indexed vs nvim_win_get_cursor 1-indexed[/+]PyDevC commentedon May 26, 2026
One easy fix would be to enforce 1 based indexing in whole program before you start working on it. So you don't have to worry about 0 indexing or 1 indexing.