Fixes crash on empty rust file. (#592)

Fixes #591

Co-authored-by: Cor Peters <luctius@gmail.com>
pull/593/head
Cor Peters 3 years ago committed by GitHub
parent 78923496a6
commit ac3c1719c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -26,7 +26,7 @@ pub fn find(syntax: &Syntax, doc: &Rope, pos: usize) -> Option<usize> {
let len = doc.len_bytes(); let len = doc.len_bytes();
let start_byte = node.start_byte(); 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 { if start_byte >= len || end_byte >= len {
return None; return None;
} }

Loading…
Cancel
Save