diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 13eb0307b..e12c80b65 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -5244,7 +5244,11 @@ fn toggle_line_comments(cx: &mut Context) { }), ); - transaction.with_selection(Selection::new(selections, selection.primary_index())) + if selections.is_empty() { + transaction + } else { + transaction.with_selection(Selection::new(selections, selection.primary_index())) + } }, ); }