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>
This commit is contained in:
parent
93ec42d06e
commit
951fd1c80e
1 changed files with 6 additions and 2 deletions
|
@ -4654,9 +4654,13 @@ fn indent(cx: &mut Context) {
|
|||
|
||||
let transaction = Transaction::change(
|
||||
doc.text(),
|
||||
lines.into_iter().map(|line| {
|
||||
lines.into_iter().filter_map(|line| {
|
||||
let is_blank = doc.text().line(line).chunks().all(|s| s.trim().is_empty());
|
||||
if is_blank {
|
||||
return None;
|
||||
}
|
||||
let pos = doc.text().line_to_char(line);
|
||||
(pos, pos, Some(indent.clone()))
|
||||
Some((pos, pos, Some(indent.clone())))
|
||||
}),
|
||||
);
|
||||
doc.apply(&transaction, view.id);
|
||||
|
|
Loading…
Add table
Reference in a new issue