mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-23 01:46:18 +04:00
Don't panic on empty file/buffer (#108)
This commit is contained in:
parent
c17dcb8633
commit
2bb71a829e
@ -25,6 +25,10 @@ pub fn find(syntax: &Syntax, doc: &Rope, pos: usize) -> Option<usize> {
|
||||
}
|
||||
|
||||
let start_byte = node.start_byte();
|
||||
let len = doc.len_bytes();
|
||||
if start_byte >= len {
|
||||
return None;
|
||||
}
|
||||
let end_byte = node.end_byte() - 1; // it's end exclusive
|
||||
let start_char = doc.byte_to_char(start_byte);
|
||||
let end_char = doc.byte_to_char(end_byte);
|
||||
|
Loading…
Reference in New Issue
Block a user