on master help sign in
fix(commands): don't indent empty lines (#1653)

* fix(commands): don't indent empty lines Fixes: https://github.com/helix-editor/helix/issues/1642 * Apply suggestions * Update helix-term/src/commands.rs * Update helix-term/src/commands.rs Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>

commit951fd1c80e9d8b39f16a8a86445263fb527d331d authorMatouš Dzivjak <matousdzivjak@gmail.com> dateFri 25 Feb 2022, 09:49 (5 years ago) parent93ec42d
1 file changed+6−2
helix-term/src/commands.rs+6−2
helix-term/src/commands.rs+6−2
@@ -4654,9 +4654,13 @@ fn indent(cx: &mut Context) {
46544654
46554655 let transaction = Transaction::change(
46564656 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+ }
46584662 let pos = doc.text().line_to_char(line);
4659− (pos, pos, Some(indent.clone()))
4663+ Some((pos, pos, Some(indent.clone())))
46604664 }),
46614665 );
46624666 doc.apply(&transaction, view.id);