Fixes crash on empty rust file. (#592)
Fixes #591 Co-authored-by: Cor Peters <luctius@gmail.com>
This commit is contained in:
parent
78923496a6
commit
ac3c1719c9
1 changed files with 1 additions and 1 deletions
|
@ -26,7 +26,7 @@ pub fn find(syntax: &Syntax, doc: &Rope, pos: usize) -> Option<usize> {
|
|||
|
||||
let len = doc.len_bytes();
|
||||
let start_byte = node.start_byte();
|
||||
let end_byte = node.end_byte() - 1; // it's end exclusive
|
||||
let end_byte = node.end_byte().saturating_sub(1); // it's end exclusive
|
||||
if start_byte >= len || end_byte >= len {
|
||||
return None;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue