Don't panic on empty file/buffer (#108)
commit2bb71a829ef61e3e64c27db93d5260be2112fc61
authornotoria <notoria@users.noreply.github.com>
dateSat 5 Jun 2021, 06:00 (5 years ago)
parentc17dcb8
helix-core/src/match_brackets.rs+4
@@ -25,6 +25,10 @@ pub fn find(syntax: &Syntax, doc: &Rope, pos: usize) -> Option<usize> {
2525 }
2626
2727 let start_byte = node.start_byte();
28+ let len = doc.len_bytes();
29+ if start_byte >= len {
30+ return None;
31+ }
2832 let end_byte = node.end_byte() - 1; // it's end exclusive
2933 let start_char = doc.byte_to_char(start_byte);
3034 let end_char = doc.byte_to_char(end_byte);