Add c and d operators to vim normal mode
Extracted motions from normal mode Changed vim_submode to be vim_operator to enable better composition of operators
This commit is contained in:
parent
670757e5c9
commit
63278041e1
10 changed files with 862 additions and 433 deletions
|
@ -1,4 +1,4 @@
|
|||
use crate::{mode::Mode, SwitchMode, VimState};
|
||||
use crate::{state::Mode, Vim};
|
||||
use editor::Bias;
|
||||
use gpui::{actions, MutableAppContext, ViewContext};
|
||||
use language::SelectionGoal;
|
||||
|
@ -11,30 +11,30 @@ pub fn init(cx: &mut MutableAppContext) {
|
|||
}
|
||||
|
||||
fn normal_before(_: &mut Workspace, _: &NormalBefore, cx: &mut ViewContext<Workspace>) {
|
||||
VimState::update_global(cx, |state, cx| {
|
||||
Vim::update(cx, |state, cx| {
|
||||
state.update_active_editor(cx, |editor, cx| {
|
||||
editor.move_cursors(cx, |map, mut cursor, _| {
|
||||
*cursor.column_mut() = cursor.column().saturating_sub(1);
|
||||
(map.clip_point(cursor, Bias::Left), SelectionGoal::None)
|
||||
});
|
||||
});
|
||||
state.switch_mode(&SwitchMode(Mode::normal()), cx);
|
||||
state.switch_mode(Mode::Normal, cx);
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::{mode::Mode, vim_test_context::VimTestContext};
|
||||
use crate::{state::Mode, vim_test_context::VimTestContext};
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_enter_and_exit_insert_mode(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = VimTestContext::new(cx, true, "").await;
|
||||
cx.simulate_keystroke("i");
|
||||
assert_eq!(cx.mode(), Mode::Insert);
|
||||
cx.simulate_keystrokes(&["T", "e", "s", "t"]);
|
||||
cx.simulate_keystrokes(["T", "e", "s", "t"]);
|
||||
cx.assert_editor_state("Test|");
|
||||
cx.simulate_keystroke("escape");
|
||||
assert_eq!(cx.mode(), Mode::normal());
|
||||
assert_eq!(cx.mode(), Mode::Normal);
|
||||
cx.assert_editor_state("Tes|t");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue