mirror of
https://github.com/zed-industries/zed.git
synced 2026-06-01 03:14:56 +07:00
vim: Add helix alias reflow for vim rewrap (#51788)
Add support for Helix's `:reflow` command when vim or helix mode is enabled. Release Notes: - Add support for helix's `:reflow` command --------- Co-authored-by: dino <dinojoaocosta@gmail.com>
This commit is contained in:
parent
f586129d2c
commit
22a33b705f
1 changed files with 51 additions and 0 deletions
|
|
@ -47,6 +47,7 @@ use crate::{
|
|||
search::{FindCommand, ReplaceCommand, Replacement},
|
||||
},
|
||||
object::Object,
|
||||
rewrap::Rewrap,
|
||||
state::{Mark, Mode},
|
||||
visual::VisualDeleteLine,
|
||||
};
|
||||
|
|
@ -1725,6 +1726,7 @@ fn generate_commands(_: &App) -> Vec<VimCommand> {
|
|||
)
|
||||
.range(wrap_count),
|
||||
VimCommand::new(("j", "oin"), JoinLines).range(select_range),
|
||||
VimCommand::new(("reflow", ""), Rewrap).range(select_range),
|
||||
VimCommand::new(("fo", "ld"), editor::actions::FoldSelectedRanges).range(act_on_range),
|
||||
VimCommand::new(("foldo", "pen"), editor::actions::UnfoldLines)
|
||||
.bang(editor::actions::UnfoldRecursive)
|
||||
|
|
@ -3537,4 +3539,53 @@ mod test {
|
|||
Mode::Normal,
|
||||
);
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_reflow(cx: &mut TestAppContext) {
|
||||
let mut cx = VimTestContext::new(cx, true).await;
|
||||
|
||||
cx.update_editor(|editor, _window, cx| {
|
||||
editor.set_hard_wrap(Some(10), cx);
|
||||
});
|
||||
|
||||
cx.set_state(
|
||||
indoc! {"
|
||||
ˇ0123456789 0123456789 0123456789 0123456789
|
||||
"},
|
||||
Mode::Normal,
|
||||
);
|
||||
|
||||
cx.simulate_keystrokes(": reflow");
|
||||
cx.simulate_keystrokes("enter");
|
||||
|
||||
cx.assert_state(
|
||||
indoc! {"
|
||||
0123456789
|
||||
0123456789
|
||||
0123456789
|
||||
ˇ0123456789
|
||||
"},
|
||||
Mode::Normal,
|
||||
);
|
||||
|
||||
cx.set_state(
|
||||
indoc! {"
|
||||
«0123456789 0123456789ˇ»
|
||||
0123456789 0123456789
|
||||
"},
|
||||
Mode::VisualLine,
|
||||
);
|
||||
|
||||
cx.simulate_keystrokes(": reflow");
|
||||
cx.simulate_keystrokes("enter");
|
||||
|
||||
cx.assert_state(
|
||||
indoc! {"
|
||||
ˇ0123456789
|
||||
0123456789
|
||||
0123456789 0123456789
|
||||
"},
|
||||
Mode::Normal,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue