on master help sign in
fix: crash with ctrl-c on empty file
commit7f6265ecf3380dea4179f49a8cc8e5734b4df174 authorBlaž Hrastnik <blaz@mxxn.io> dateThu 24 Jun 2021, 01:38 (5 years ago) parent0f55e67
1 file changed+1−1
helix-core/src/comment.rs+1−1
helix-core/src/comment.rs+1−1
@@ -51,7 +51,7 @@ pub fn toggle_line_comments(doc: &Rope, selection: &Selection) -> Transaction {
5151 let lines = start..end + 1;
5252 let (commented, skipped, min) = find_line_comment(token, text, lines.clone());
5353
54− changes.reserve(end - start - skipped.len());
54+ changes.reserve((end - start).saturating_sub(skipped.len()));
5555
5656 for line in lines {
5757 if skipped.contains(&line) {