From c3e8cae20f7248748541e447a8d782e8c3392c74 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Mon, 26 Jun 2023 10:08:34 -0600 Subject: [PATCH] vim: indent/outdent Fixes: zed-industries/community#832 --- assets/keymaps/vim.json | 8 ++++++-- crates/vim/src/test.rs | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/assets/keymaps/vim.json b/assets/keymaps/vim.json index 43b778d9b8..d621bd0e49 100644 --- a/assets/keymaps/vim.json +++ b/assets/keymaps/vim.json @@ -221,7 +221,9 @@ "vim::PushOperator", "Replace" ], - "s": "vim::Substitute" + "s": "vim::Substitute", + "> >": "editor::Indent", + "< <": "editor::Outdent" } }, { @@ -312,7 +314,9 @@ "r": [ "vim::PushOperator", "Replace" - ] + ], + "> >": "editor::Indent", + "< <": "editor::Outdent" } }, { diff --git a/crates/vim/src/test.rs b/crates/vim/src/test.rs index 075229c47f..b6c5b7ca51 100644 --- a/crates/vim/src/test.rs +++ b/crates/vim/src/test.rs @@ -123,3 +123,19 @@ async fn test_end_of_document_710(cx: &mut gpui::TestAppContext) { cx.simulate_keystrokes(["1", "shift-g"]); cx.assert_editor_state("aˇa\nbb\ncc"); } + +#[gpui::test] +async fn test_indent_outdent(cx: &mut gpui::TestAppContext) { + let mut cx = VimTestContext::new(cx, true).await; + + // works in normal mode + cx.set_state(indoc! {"aa\nbˇb\ncc"}, Mode::Normal); + cx.simulate_keystrokes([">", ">"]); + cx.assert_editor_state("aa\n bˇb\ncc"); + cx.simulate_keystrokes(["<", "<"]); + cx.assert_editor_state("aa\nbˇb\ncc"); + + // works in visuial mode + cx.simulate_keystrokes(["shift-v", "down", ">", ">"]); + cx.assert_editor_state("aa\n b«b\n cˇ»c"); +}