Fix ocassional panic when matching brackets.
This commit is contained in:
parent
fd684ef693
commit
ffb8057a7f
1 changed files with 4 additions and 3 deletions
|
@ -24,12 +24,13 @@ pub fn find(syntax: &Syntax, doc: &Rope, pos: usize) -> Option<usize> {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let start_byte = node.start_byte();
|
|
||||||
let len = doc.len_bytes();
|
let len = doc.len_bytes();
|
||||||
if start_byte >= len {
|
let start_byte = node.start_byte();
|
||||||
|
let end_byte = node.end_byte() - 1; // it's end exclusive
|
||||||
|
if start_byte >= len || end_byte >= len {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let end_byte = node.end_byte() - 1; // it's end exclusive
|
|
||||||
let start_char = doc.byte_to_char(start_byte);
|
let start_char = doc.byte_to_char(start_byte);
|
||||||
let end_char = doc.byte_to_char(end_byte);
|
let end_char = doc.byte_to_char(end_byte);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue