aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCor Peters2021-08-16 10:18:23 +0000
committerGitHub2021-08-16 10:18:23 +0000
commitac3c1719c968cdad7b17a7a8a115bc722928bbb9 (patch)
treef33f50f4c81d73ca2a9a0de7f357c3edecf5f501
parent78923496a6134ab456dbfe8c0a58270d32e4b239 (diff)
Fixes crash on empty rust file. (#592)
Fixes #591 Co-authored-by: Cor Peters <luctius@gmail.com>
-rw-r--r--helix-core/src/match_brackets.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/helix-core/src/match_brackets.rs b/helix-core/src/match_brackets.rs
index f3d9e845..a4b2fb9c 100644
--- a/helix-core/src/match_brackets.rs
+++ b/helix-core/src/match_brackets.rs
@@ -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;
}