From 7f6265ecf3380dea4179f49a8cc8e5734b4df174 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Thu, 24 Jun 2021 01:38:02 +0900 Subject: [PATCH] fix: crash with ctrl-c on empty file --- helix-core/src/comment.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helix-core/src/comment.rs b/helix-core/src/comment.rs index dff99babd..07f685d83 100644 --- a/helix-core/src/comment.rs +++ b/helix-core/src/comment.rs @@ -51,7 +51,7 @@ pub fn toggle_line_comments(doc: &Rope, selection: &Selection) -> Transaction { let lines = start..end + 1; let (commented, skipped, min) = find_line_comment(token, text, lines.clone()); - changes.reserve(end - start - skipped.len()); + changes.reserve((end - start).saturating_sub(skipped.len())); for line in lines { if skipped.contains(&line) {