From ac3c1719c968cdad7b17a7a8a115bc722928bbb9 Mon Sep 17 00:00:00 2001 From: Cor Peters Date: Mon, 16 Aug 2021 12:18:23 +0200 Subject: 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(-) (limited to 'helix-core/src') 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 { 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; } -- cgit v1.2.3-70-g09d2