vim: ctrl-r while we're on a register kick (#13085)
Release Notes: - vim: Support `ctrl-r X` to paste in insert mode (#4308)
This commit is contained in:
parent
e6def62c23
commit
fc19cc0ddf
6 changed files with 122 additions and 83 deletions
|
@ -16,6 +16,11 @@ pub fn register(workspace: &mut Workspace, _: &mut ViewContext<Workspace>) {
|
|||
|
||||
fn normal_before(_: &mut Workspace, action: &NormalBefore, cx: &mut ViewContext<Workspace>) {
|
||||
let should_repeat = Vim::update(cx, |vim, cx| {
|
||||
if vim.state().active_operator().is_some() {
|
||||
vim.update_state(|state| state.operator_stack.clear());
|
||||
vim.sync_vim_settings(cx);
|
||||
return false;
|
||||
}
|
||||
let count = vim.take_count(cx).unwrap_or(1);
|
||||
vim.stop_recording_immediately(action.boxed_clone());
|
||||
if count <= 1 || vim.workspace_state.replaying {
|
||||
|
@ -66,30 +71,24 @@ mod test {
|
|||
|
||||
cx.set_shared_state("ˇhello\n").await;
|
||||
cx.simulate_shared_keystrokes("5 i - escape").await;
|
||||
cx.run_until_parked();
|
||||
cx.shared_state().await.assert_eq("----ˇ-hello\n");
|
||||
|
||||
cx.set_shared_state("ˇhello\n").await;
|
||||
cx.simulate_shared_keystrokes("5 a - escape").await;
|
||||
cx.run_until_parked();
|
||||
cx.shared_state().await.assert_eq("h----ˇ-ello\n");
|
||||
|
||||
cx.simulate_shared_keystrokes("4 shift-i - escape").await;
|
||||
cx.run_until_parked();
|
||||
cx.shared_state().await.assert_eq("---ˇ-h-----ello\n");
|
||||
|
||||
cx.simulate_shared_keystrokes("3 shift-a - escape").await;
|
||||
cx.run_until_parked();
|
||||
cx.shared_state().await.assert_eq("----h-----ello--ˇ-\n");
|
||||
|
||||
cx.set_shared_state("ˇhello\n").await;
|
||||
cx.simulate_shared_keystrokes("3 o o i escape").await;
|
||||
cx.run_until_parked();
|
||||
cx.shared_state().await.assert_eq("hello\noi\noi\noˇi\n");
|
||||
|
||||
cx.set_shared_state("ˇhello\n").await;
|
||||
cx.simulate_shared_keystrokes("3 shift-o o i escape").await;
|
||||
cx.run_until_parked();
|
||||
cx.shared_state().await.assert_eq("oi\noi\noˇi\nhello\n");
|
||||
}
|
||||
|
||||
|
@ -99,28 +98,31 @@ mod test {
|
|||
|
||||
cx.set_shared_state("ˇhello\n").await;
|
||||
cx.simulate_shared_keystrokes("3 i - escape").await;
|
||||
cx.run_until_parked();
|
||||
cx.shared_state().await.assert_eq("--ˇ-hello\n");
|
||||
cx.simulate_shared_keystrokes(".").await;
|
||||
cx.run_until_parked();
|
||||
cx.shared_state().await.assert_eq("----ˇ--hello\n");
|
||||
cx.simulate_shared_keystrokes("2 .").await;
|
||||
cx.run_until_parked();
|
||||
cx.shared_state().await.assert_eq("-----ˇ---hello\n");
|
||||
|
||||
cx.set_shared_state("ˇhello\n").await;
|
||||
cx.simulate_shared_keystrokes("2 o k k escape").await;
|
||||
cx.run_until_parked();
|
||||
cx.shared_state().await.assert_eq("hello\nkk\nkˇk\n");
|
||||
cx.simulate_shared_keystrokes(".").await;
|
||||
cx.run_until_parked();
|
||||
cx.shared_state()
|
||||
.await
|
||||
.assert_eq("hello\nkk\nkk\nkk\nkˇk\n");
|
||||
cx.simulate_shared_keystrokes("1 .").await;
|
||||
cx.run_until_parked();
|
||||
cx.shared_state()
|
||||
.await
|
||||
.assert_eq("hello\nkk\nkk\nkk\nkk\nkˇk\n");
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_insert_ctrl_r(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
|
||||
cx.set_shared_state("heˇllo\n").await;
|
||||
cx.simulate_shared_keystrokes("y y i ctrl-r \"").await;
|
||||
cx.shared_state().await.assert_eq("hehello\nˇllo\n");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue