mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-08 07:35:01 +03:00
vim: Fix count in visual indent (#15296)
Co-Authored-By: tobbe@tlundberg.com Release Notes: - vim: Added {count} for `>`/`<` in visual mode
This commit is contained in:
parent
bcd972fbb4
commit
c8bc49fa18
@ -157,10 +157,13 @@ pub(crate) fn register(workspace: &mut Workspace, cx: &mut ViewContext<Workspace
|
|||||||
workspace.register_action(|_: &mut Workspace, _: &Indent, cx| {
|
workspace.register_action(|_: &mut Workspace, _: &Indent, cx| {
|
||||||
Vim::update(cx, |vim, cx| {
|
Vim::update(cx, |vim, cx| {
|
||||||
vim.record_current_action(cx);
|
vim.record_current_action(cx);
|
||||||
|
let count = vim.take_count(cx).unwrap_or(1);
|
||||||
vim.update_active_editor(cx, |_, editor, cx| {
|
vim.update_active_editor(cx, |_, editor, cx| {
|
||||||
editor.transact(cx, |editor, cx| {
|
editor.transact(cx, |editor, cx| {
|
||||||
let mut original_positions = save_selection_starts(editor, cx);
|
let mut original_positions = save_selection_starts(editor, cx);
|
||||||
|
for _ in 0..count {
|
||||||
editor.indent(&Default::default(), cx);
|
editor.indent(&Default::default(), cx);
|
||||||
|
}
|
||||||
restore_selection_cursors(editor, cx, &mut original_positions);
|
restore_selection_cursors(editor, cx, &mut original_positions);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -173,10 +176,13 @@ pub(crate) fn register(workspace: &mut Workspace, cx: &mut ViewContext<Workspace
|
|||||||
workspace.register_action(|_: &mut Workspace, _: &Outdent, cx| {
|
workspace.register_action(|_: &mut Workspace, _: &Outdent, cx| {
|
||||||
Vim::update(cx, |vim, cx| {
|
Vim::update(cx, |vim, cx| {
|
||||||
vim.record_current_action(cx);
|
vim.record_current_action(cx);
|
||||||
|
let count = vim.take_count(cx).unwrap_or(1);
|
||||||
vim.update_active_editor(cx, |_, editor, cx| {
|
vim.update_active_editor(cx, |_, editor, cx| {
|
||||||
editor.transact(cx, |editor, cx| {
|
editor.transact(cx, |editor, cx| {
|
||||||
let mut original_positions = save_selection_starts(editor, cx);
|
let mut original_positions = save_selection_starts(editor, cx);
|
||||||
|
for _ in 0..count {
|
||||||
editor.outdent(&Default::default(), cx);
|
editor.outdent(&Default::default(), cx);
|
||||||
|
}
|
||||||
restore_selection_cursors(editor, cx, &mut original_positions);
|
restore_selection_cursors(editor, cx, &mut original_positions);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1438,3 +1438,13 @@ async fn test_ctrl_w_override(cx: &mut gpui::TestAppContext) {
|
|||||||
cx.simulate_shared_keystrokes("ctrl-w").await;
|
cx.simulate_shared_keystrokes("ctrl-w").await;
|
||||||
cx.shared_state().await.assert_eq("ˇ");
|
cx.shared_state().await.assert_eq("ˇ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[gpui::test]
|
||||||
|
async fn test_visual_indent_count(cx: &mut gpui::TestAppContext) {
|
||||||
|
let mut cx = VimTestContext::new(cx, true).await;
|
||||||
|
cx.set_state("ˇhi", Mode::Normal);
|
||||||
|
cx.simulate_keystrokes("shift-v 3 >");
|
||||||
|
cx.assert_state(" ˇhi", Mode::Normal);
|
||||||
|
cx.simulate_keystrokes("shift-v 2 <");
|
||||||
|
cx.assert_state(" ˇhi", Mode::Normal);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user