aboutsummaryrefslogtreecommitdiff
path: root/helix-core
diff options
context:
space:
mode:
authorNathan Vegdahl2021-07-23 01:45:43 +0000
committerNathan Vegdahl2021-07-23 01:47:37 +0000
commitffb8057a7fcd65b5caaa1e86b66c6f6e0fb5270f (patch)
treec7dec178fe2cc89f277b8bdea7748be61bcdee05 /helix-core
parentfd684ef6931d11632274d87c9a42d4fabb51c074 (diff)
Fix ocassional panic when matching brackets.
Diffstat (limited to 'helix-core')
-rw-r--r--helix-core/src/match_brackets.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/helix-core/src/match_brackets.rs b/helix-core/src/match_brackets.rs
index 2aa87620..f3d9e845 100644
--- a/helix-core/src/match_brackets.rs
+++ b/helix-core/src/match_brackets.rs
@@ -24,12 +24,13 @@ pub fn find(syntax: &Syntax, doc: &Rope, pos: usize) -> Option<usize> {
return None;
}
- let start_byte = node.start_byte();
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;
}
- 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);