mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-22 17:36:19 +04:00
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
@ -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…
Reference in New Issue
Block a user