Skip to content

Commit 5a1dcc2

Browse files
committed
syntax: Reset query cursor byte range for textobjects
`InactiveQueryCursor::new` might reuse a query cursor from a thread-local cache if one is available, rather than create a new cursor. Currently tree-house does not reset cached cursors back to defaults (i.e. byte range and match limit). For now we can patch around this here but eventually this should be fixed in `tree-house` upstream. Then this patch can be reverted. In practice this caused textobjects like `]f` to get "stuck" trying to move to the next function if it was out of the current view. This is because the highlight query cursor sets the range of the cursor to the current viewport. We can reset the byte range to defaults to fix the textobject behavior.
1 parent be1bf2f commit 5a1dcc2

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

helix-core/src/syntax.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,9 @@ impl TextObjectQuery {
865865
.find_map(|cap| self.query.get_capture(cap))?;
866866

867867
let mut cursor = InactiveQueryCursor::new();
868+
// TODO: this line can be dropped when we update tree-house to automatically reset cursors
869+
// back to defaults when reusing them from the cursor cache.
870+
cursor.set_byte_range(0..u32::MAX);
868871
cursor.set_match_limit(TREE_SITTER_MATCH_LIMIT);
869872
let mut cursor = cursor.execute_query(&self.query, node, RopeInput::new(slice));
870873
let capture_node = iter::from_fn(move || {

0 commit comments

Comments
 (0)