Skip to content

Commit 2bb71a8

Browse files
authored
Don't panic on empty file/buffer (#108)
1 parent c17dcb8 commit 2bb71a8

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

helix-core/src/match_brackets.rs

+4
Original file line numberDiff line numberDiff line change
@@ -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);

0 commit comments

Comments
 (0)