on master help sign in
Fix ocassional panic when matching brackets.
commitffb8057a7fcd65b5caaa1e86b66c6f6e0fb5270f authorNathan Vegdahl <cessen@cessen.com> dateThu 22 Jul 2021, 18:45 (5 years ago) parentfd684ef
1 file changed+4−3
helix-core/src/match_brackets.rs+4−3
helix-core/src/match_brackets.rs+4−3
@@ -24,12 +24,13 @@ pub fn find(syntax: &Syntax, doc: &Rope, pos: usize) -> Option<usize> {
2424 return None;
2525 }
2626
27− let start_byte = node.start_byte();
2827 let len = doc.len_bytes();
29− if start_byte >= len {
28+ let start_byte = node.start_byte();
29+ let end_byte = node.end_byte() - 1; // it's end exclusive
30+ if start_byte >= len || end_byte >= len {
3031 return None;
3132 }
32− let end_byte = node.end_byte() - 1; // it's end exclusive
33+
3334 let start_char = doc.byte_to_char(start_byte);
3435 let end_char = doc.byte_to_char(end_byte);
3536