From ac3c1719c968cdad7b17a7a8a115bc722928bbb9 Mon Sep 17 00:00:00 2001 From: Cor Peters Date: Mon, 16 Aug 2021 12:18:23 +0200 Subject: [PATCH] Fixes crash on empty rust file. (#592) Fixes #591 Co-authored-by: Cor Peters --- helix-core/src/match_brackets.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helix-core/src/match_brackets.rs b/helix-core/src/match_brackets.rs index f3d9e845e..a4b2fb9c8 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 { 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; }