on master help sign in
fix(commands): don't indent empty lines (#1653)
951fd1cMatouš Dzivjak
helix-term/src/commands.rs+6−2
@@ -4654,9 +4654,13 @@ fn indent(cx: &mut Context) {
4654
4654
4655 let transaction = Transaction::change(
4655 let transaction = Transaction::change(
4656 doc.text(),
4656 doc.text(),
4657− lines.into_iter().map(|line| {
4657+ lines.into_iter().filter_map(|line| {
4658+ let is_blank = doc.text().line(line).chunks().all(|s| s.trim().is_empty());
4659+ if is_blank {
4660+ return None;
4661+ }
4658 let pos = doc.text().line_to_char(line);
4662 let pos = doc.text().line_to_char(line);
4659− (pos, pos, Some(indent.clone()))
4663+ Some((pos, pos, Some(indent.clone())))
4660 }),
4664 }),
4661 );
4665 );
4662 doc.apply(&transaction, view.id);
4666 doc.apply(&transaction, view.id);