on master help sign in
Set byte range on cursor again
commit2f4a9fea03ffc7a2fb71ded0281d388289eceba9 authorBlaž Hrastnik <blaz@mxxn.io> dateMon 10 Jan 2022, 00:42 (5 years ago) parent24314bd
1 file changed+5−2
helix-core/src/syntax.rs+5−2
helix-core/src/syntax.rs+5−2
@@ -560,6 +560,7 @@ impl Syntax {
560560 let ts_parser = &mut ts_parser.borrow_mut();
561561 let mut cursor = ts_parser.cursors.pop().unwrap_or_else(QueryCursor::new);
562562 // TODO: might need to set cursor range
563+ cursor.set_byte_range(0..usize::MAX);
563564
564565 let source_slice = source.slice(..);
565566
@@ -729,6 +730,9 @@ impl Syntax {
729730 highlighter.cursors.pop().unwrap_or_else(QueryCursor::new)
730731 });
731732
733+ // TODO: if range doesn't overlap layer range, skip it
734+ // we can calculate intersection and use it later for set_byte_range
735+
732736 // The `captures` iterator borrows the `Tree` and the `QueryCursor`, which
733737 // prevents them from being moved. But both of these values are really just
734738 // pointers, so it's actually ok to move them.
@@ -737,8 +741,7 @@ impl Syntax {
737741
738742 // if reusing cursors & no range this resets to whole range
739743 // TODO: handle intersect (range & layer.range)
740− // cursor_ref.set_byte_range(range.clone().unwrap_or(0..usize::MAX));
741− cursor_ref.set_byte_range(0..usize::MAX);
744+ cursor_ref.set_byte_range(range.clone().unwrap_or(0..usize::MAX));
742745
743746 let mut captures = cursor_ref
744747 .captures(