diff options
author | Blaž Hrastnik | 2021-06-23 16:38:02 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-06-23 16:38:02 +0000 |
commit | 7f6265ecf3380dea4179f49a8cc8e5734b4df174 (patch) | |
tree | 5d013bd2944fec9e59412bc3a5f0dd9e0b061a83 | |
parent | 0f55e67576ef6b9cd0c560100db43cb3023c5ef7 (diff) |
fix: crash with ctrl-c on empty file
-rw-r--r-- | helix-core/src/comment.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/helix-core/src/comment.rs b/helix-core/src/comment.rs index dff99bab..07f685d8 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) { |