vim test redux (#11709)
This cleans up the neovim-backed vim tests: - removed exempted tests (we'll rely on bug reports to find missing edge cases) - moved all assertions into non-async fn's so that failures are reporting on the right file/line - removed the NeovimBackedBindingTestContext - renamed a few things to make them clearer - reduced the number of permutations tested in some cases to reduce slowest test from 60s to 5s Release Notes: - N/A
This commit is contained in:
parent
48cba328f2
commit
f550f23b97
38 changed files with 2311 additions and 6505 deletions
|
@ -111,35 +111,35 @@ mod test {
|
|||
async fn test_change_case(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.set_shared_state("ˇabC\n").await;
|
||||
cx.simulate_shared_keystrokes(["~"]).await;
|
||||
cx.assert_shared_state("AˇbC\n").await;
|
||||
cx.simulate_shared_keystrokes(["2", "~"]).await;
|
||||
cx.assert_shared_state("ABˇc\n").await;
|
||||
cx.simulate_shared_keystrokes("~").await;
|
||||
cx.shared_state().await.assert_eq("AˇbC\n");
|
||||
cx.simulate_shared_keystrokes("2 ~").await;
|
||||
cx.shared_state().await.assert_eq("ABˇc\n");
|
||||
|
||||
// works in visual mode
|
||||
cx.set_shared_state("a😀C«dÉ1*fˇ»\n").await;
|
||||
cx.simulate_shared_keystrokes(["~"]).await;
|
||||
cx.assert_shared_state("a😀CˇDé1*F\n").await;
|
||||
cx.simulate_shared_keystrokes("~").await;
|
||||
cx.shared_state().await.assert_eq("a😀CˇDé1*F\n");
|
||||
|
||||
// works with multibyte characters
|
||||
cx.simulate_shared_keystrokes(["~"]).await;
|
||||
cx.simulate_shared_keystrokes("~").await;
|
||||
cx.set_shared_state("aˇC😀é1*F\n").await;
|
||||
cx.simulate_shared_keystrokes(["4", "~"]).await;
|
||||
cx.assert_shared_state("ac😀É1ˇ*F\n").await;
|
||||
cx.simulate_shared_keystrokes("4 ~").await;
|
||||
cx.shared_state().await.assert_eq("ac😀É1ˇ*F\n");
|
||||
|
||||
// works with line selections
|
||||
cx.set_shared_state("abˇC\n").await;
|
||||
cx.simulate_shared_keystrokes(["shift-v", "~"]).await;
|
||||
cx.assert_shared_state("ˇABc\n").await;
|
||||
cx.simulate_shared_keystrokes("shift-v ~").await;
|
||||
cx.shared_state().await.assert_eq("ˇABc\n");
|
||||
|
||||
// works in visual block mode
|
||||
cx.set_shared_state("ˇaa\nbb\ncc").await;
|
||||
cx.simulate_shared_keystrokes(["ctrl-v", "j", "~"]).await;
|
||||
cx.assert_shared_state("ˇAa\nBb\ncc").await;
|
||||
cx.simulate_shared_keystrokes("ctrl-v j ~").await;
|
||||
cx.shared_state().await.assert_eq("ˇAa\nBb\ncc");
|
||||
|
||||
// works with multiple cursors (zed only)
|
||||
cx.set_state("aˇßcdˇe\n", Mode::Normal);
|
||||
cx.simulate_keystroke("~");
|
||||
cx.simulate_keystrokes("~");
|
||||
cx.assert_state("aSSˇcdˇE\n", Mode::Normal);
|
||||
}
|
||||
|
||||
|
@ -148,18 +148,18 @@ mod test {
|
|||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
// works in visual mode
|
||||
cx.set_shared_state("a😀C«dÉ1*fˇ»\n").await;
|
||||
cx.simulate_shared_keystrokes(["U"]).await;
|
||||
cx.assert_shared_state("a😀CˇDÉ1*F\n").await;
|
||||
cx.simulate_shared_keystrokes("U").await;
|
||||
cx.shared_state().await.assert_eq("a😀CˇDÉ1*F\n");
|
||||
|
||||
// works with line selections
|
||||
cx.set_shared_state("abˇC\n").await;
|
||||
cx.simulate_shared_keystrokes(["shift-v", "U"]).await;
|
||||
cx.assert_shared_state("ˇABC\n").await;
|
||||
cx.simulate_shared_keystrokes("shift-v U").await;
|
||||
cx.shared_state().await.assert_eq("ˇABC\n");
|
||||
|
||||
// works in visual block mode
|
||||
cx.set_shared_state("ˇaa\nbb\ncc").await;
|
||||
cx.simulate_shared_keystrokes(["ctrl-v", "j", "U"]).await;
|
||||
cx.assert_shared_state("ˇAa\nBb\ncc").await;
|
||||
cx.simulate_shared_keystrokes("ctrl-v j U").await;
|
||||
cx.shared_state().await.assert_eq("ˇAa\nBb\ncc");
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
|
@ -167,17 +167,17 @@ mod test {
|
|||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
// works in visual mode
|
||||
cx.set_shared_state("A😀c«DÉ1*fˇ»\n").await;
|
||||
cx.simulate_shared_keystrokes(["u"]).await;
|
||||
cx.assert_shared_state("A😀cˇdé1*f\n").await;
|
||||
cx.simulate_shared_keystrokes("u").await;
|
||||
cx.shared_state().await.assert_eq("A😀cˇdé1*f\n");
|
||||
|
||||
// works with line selections
|
||||
cx.set_shared_state("ABˇc\n").await;
|
||||
cx.simulate_shared_keystrokes(["shift-v", "u"]).await;
|
||||
cx.assert_shared_state("ˇabc\n").await;
|
||||
cx.simulate_shared_keystrokes("shift-v u").await;
|
||||
cx.shared_state().await.assert_eq("ˇabc\n");
|
||||
|
||||
// works in visual block mode
|
||||
cx.set_shared_state("ˇAa\nBb\nCc").await;
|
||||
cx.simulate_shared_keystrokes(["ctrl-v", "j", "u"]).await;
|
||||
cx.assert_shared_state("ˇaa\nbb\nCc").await;
|
||||
cx.simulate_shared_keystrokes("ctrl-v j u").await;
|
||||
cx.shared_state().await.assert_eq("ˇaa\nbb\nCc");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -169,329 +169,401 @@ mod test {
|
|||
|
||||
#[gpui::test]
|
||||
async fn test_change_h(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await.binding(["c", "h"]);
|
||||
cx.assert("Teˇst").await;
|
||||
cx.assert("Tˇest").await;
|
||||
cx.assert("ˇTest").await;
|
||||
cx.assert(indoc! {"
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.simulate("c h", "Teˇst").await.assert_matches();
|
||||
cx.simulate("c h", "Tˇest").await.assert_matches();
|
||||
cx.simulate("c h", "ˇTest").await.assert_matches();
|
||||
cx.simulate(
|
||||
"c h",
|
||||
indoc! {"
|
||||
Test
|
||||
ˇtest"})
|
||||
.await;
|
||||
ˇtest"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_change_backspace(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx)
|
||||
.await
|
||||
.binding(["c", "backspace"]);
|
||||
cx.assert("Teˇst").await;
|
||||
cx.assert("Tˇest").await;
|
||||
cx.assert("ˇTest").await;
|
||||
cx.assert(indoc! {"
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.simulate("c backspace", "Teˇst").await.assert_matches();
|
||||
cx.simulate("c backspace", "Tˇest").await.assert_matches();
|
||||
cx.simulate("c backspace", "ˇTest").await.assert_matches();
|
||||
cx.simulate(
|
||||
"c backspace",
|
||||
indoc! {"
|
||||
Test
|
||||
ˇtest"})
|
||||
.await;
|
||||
ˇtest"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_change_l(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await.binding(["c", "l"]);
|
||||
cx.assert("Teˇst").await;
|
||||
cx.assert("Tesˇt").await;
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.simulate("c l", "Teˇst").await.assert_matches();
|
||||
cx.simulate("c l", "Tesˇt").await.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_change_w(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await.binding(["c", "w"]);
|
||||
cx.assert("Teˇst").await;
|
||||
cx.assert("Tˇest test").await;
|
||||
cx.assert("Testˇ test").await;
|
||||
cx.assert("Tesˇt test").await;
|
||||
cx.assert(indoc! {"
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.simulate("c w", "Teˇst").await.assert_matches();
|
||||
cx.simulate("c w", "Tˇest test").await.assert_matches();
|
||||
cx.simulate("c w", "Testˇ test").await.assert_matches();
|
||||
cx.simulate("c w", "Tesˇt test").await.assert_matches();
|
||||
cx.simulate(
|
||||
"c w",
|
||||
indoc! {"
|
||||
Test teˇst
|
||||
test"})
|
||||
.await;
|
||||
cx.assert(indoc! {"
|
||||
test"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"c w",
|
||||
indoc! {"
|
||||
Test tesˇt
|
||||
test"})
|
||||
.await;
|
||||
cx.assert(indoc! {"
|
||||
test"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"c w",
|
||||
indoc! {"
|
||||
Test test
|
||||
ˇ
|
||||
test"})
|
||||
.await;
|
||||
test"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
|
||||
let mut cx = cx.binding(["c", "shift-w"]);
|
||||
cx.assert("Test teˇst-test test").await;
|
||||
cx.simulate("c shift-w", "Test teˇst-test test")
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_change_e(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await.binding(["c", "e"]);
|
||||
cx.assert("Teˇst Test").await;
|
||||
cx.assert("Tˇest test").await;
|
||||
cx.assert(indoc! {"
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.simulate("c e", "Teˇst Test").await.assert_matches();
|
||||
cx.simulate("c e", "Tˇest test").await.assert_matches();
|
||||
cx.simulate(
|
||||
"c e",
|
||||
indoc! {"
|
||||
Test teˇst
|
||||
test"})
|
||||
.await;
|
||||
cx.assert(indoc! {"
|
||||
test"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"c e",
|
||||
indoc! {"
|
||||
Test tesˇt
|
||||
test"})
|
||||
.await;
|
||||
cx.assert(indoc! {"
|
||||
test"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"c e",
|
||||
indoc! {"
|
||||
Test test
|
||||
ˇ
|
||||
test"})
|
||||
.await;
|
||||
test"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
|
||||
let mut cx = cx.binding(["c", "shift-e"]);
|
||||
cx.assert("Test teˇst-test test").await;
|
||||
cx.simulate("c shift-e", "Test teˇst-test test")
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_change_b(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await.binding(["c", "b"]);
|
||||
cx.assert("Teˇst Test").await;
|
||||
cx.assert("Test ˇtest").await;
|
||||
cx.assert("Test1 test2 ˇtest3").await;
|
||||
cx.assert(indoc! {"
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.simulate("c b", "Teˇst Test").await.assert_matches();
|
||||
cx.simulate("c b", "Test ˇtest").await.assert_matches();
|
||||
cx.simulate("c b", "Test1 test2 ˇtest3")
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"c b",
|
||||
indoc! {"
|
||||
Test test
|
||||
ˇtest"})
|
||||
.await;
|
||||
cx.assert(indoc! {"
|
||||
ˇtest"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"c b",
|
||||
indoc! {"
|
||||
Test test
|
||||
ˇ
|
||||
test"})
|
||||
.await;
|
||||
test"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
|
||||
let mut cx = cx.binding(["c", "shift-b"]);
|
||||
cx.assert("Test test-test ˇtest").await;
|
||||
cx.simulate("c shift-b", "Test test-test ˇtest")
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_change_end_of_line(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await.binding(["c", "$"]);
|
||||
cx.assert(indoc! {"
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.simulate(
|
||||
"c $",
|
||||
indoc! {"
|
||||
The qˇuick
|
||||
brown fox"})
|
||||
.await;
|
||||
cx.assert(indoc! {"
|
||||
brown fox"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"c $",
|
||||
indoc! {"
|
||||
The quick
|
||||
ˇ
|
||||
brown fox"})
|
||||
.await;
|
||||
brown fox"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_change_0(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
|
||||
cx.assert_neovim_compatible(
|
||||
cx.simulate(
|
||||
"c 0",
|
||||
indoc! {"
|
||||
The qˇuick
|
||||
brown fox"},
|
||||
["c", "0"],
|
||||
)
|
||||
.await;
|
||||
cx.assert_neovim_compatible(
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"c 0",
|
||||
indoc! {"
|
||||
The quick
|
||||
ˇ
|
||||
brown fox"},
|
||||
["c", "0"],
|
||||
)
|
||||
.await;
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_change_k(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
|
||||
cx.assert_neovim_compatible(
|
||||
cx.simulate(
|
||||
"c k",
|
||||
indoc! {"
|
||||
The quick
|
||||
brown ˇfox
|
||||
jumps over"},
|
||||
["c", "k"],
|
||||
)
|
||||
.await;
|
||||
cx.assert_neovim_compatible(
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"c k",
|
||||
indoc! {"
|
||||
The quick
|
||||
brown fox
|
||||
jumps ˇover"},
|
||||
["c", "k"],
|
||||
)
|
||||
.await;
|
||||
cx.assert_neovim_compatible(
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"c k",
|
||||
indoc! {"
|
||||
The qˇuick
|
||||
brown fox
|
||||
jumps over"},
|
||||
["c", "k"],
|
||||
)
|
||||
.await;
|
||||
cx.assert_neovim_compatible(
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"c k",
|
||||
indoc! {"
|
||||
ˇ
|
||||
brown fox
|
||||
jumps over"},
|
||||
["c", "k"],
|
||||
)
|
||||
.await;
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_change_j(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.assert_neovim_compatible(
|
||||
cx.simulate(
|
||||
"c j",
|
||||
indoc! {"
|
||||
The quick
|
||||
brown ˇfox
|
||||
jumps over"},
|
||||
["c", "j"],
|
||||
)
|
||||
.await;
|
||||
cx.assert_neovim_compatible(
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"c j",
|
||||
indoc! {"
|
||||
The quick
|
||||
brown fox
|
||||
jumps ˇover"},
|
||||
["c", "j"],
|
||||
)
|
||||
.await;
|
||||
cx.assert_neovim_compatible(
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"c j",
|
||||
indoc! {"
|
||||
The qˇuick
|
||||
brown fox
|
||||
jumps over"},
|
||||
["c", "j"],
|
||||
)
|
||||
.await;
|
||||
cx.assert_neovim_compatible(
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"c j",
|
||||
indoc! {"
|
||||
The quick
|
||||
brown fox
|
||||
ˇ"},
|
||||
["c", "j"],
|
||||
)
|
||||
.await;
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_change_end_of_document(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.assert_neovim_compatible(
|
||||
cx.simulate(
|
||||
"c shift-g",
|
||||
indoc! {"
|
||||
The quick
|
||||
brownˇ fox
|
||||
jumps over
|
||||
the lazy"},
|
||||
["c", "shift-g"],
|
||||
)
|
||||
.await;
|
||||
cx.assert_neovim_compatible(
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"c shift-g",
|
||||
indoc! {"
|
||||
The quick
|
||||
brownˇ fox
|
||||
jumps over
|
||||
the lazy"},
|
||||
["c", "shift-g"],
|
||||
)
|
||||
.await;
|
||||
cx.assert_neovim_compatible(
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"c shift-g",
|
||||
indoc! {"
|
||||
The quick
|
||||
brown fox
|
||||
jumps over
|
||||
the lˇazy"},
|
||||
["c", "shift-g"],
|
||||
)
|
||||
.await;
|
||||
cx.assert_neovim_compatible(
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"c shift-g",
|
||||
indoc! {"
|
||||
The quick
|
||||
brown fox
|
||||
jumps over
|
||||
ˇ"},
|
||||
["c", "shift-g"],
|
||||
)
|
||||
.await;
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_change_cc(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.assert_neovim_compatible(
|
||||
cx.simulate(
|
||||
"c c",
|
||||
indoc! {"
|
||||
The quick
|
||||
brownˇ fox
|
||||
jumps over
|
||||
the lazy"},
|
||||
["c", "c"],
|
||||
)
|
||||
.await;
|
||||
.await
|
||||
.assert_matches();
|
||||
|
||||
cx.assert_neovim_compatible(
|
||||
cx.simulate(
|
||||
"c c",
|
||||
indoc! {"
|
||||
ˇThe quick
|
||||
brown fox
|
||||
jumps over
|
||||
the lazy"},
|
||||
["c", "c"],
|
||||
)
|
||||
.await;
|
||||
.await
|
||||
.assert_matches();
|
||||
|
||||
cx.assert_neovim_compatible(
|
||||
cx.simulate(
|
||||
"c c",
|
||||
indoc! {"
|
||||
The quick
|
||||
broˇwn fox
|
||||
jumˇps over
|
||||
jumps over
|
||||
the lazy"},
|
||||
["c", "c"],
|
||||
)
|
||||
.await;
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_change_gg(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.assert_neovim_compatible(
|
||||
cx.simulate(
|
||||
"c g g",
|
||||
indoc! {"
|
||||
The quick
|
||||
brownˇ fox
|
||||
jumps over
|
||||
the lazy"},
|
||||
["c", "g", "g"],
|
||||
)
|
||||
.await;
|
||||
cx.assert_neovim_compatible(
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"c g g",
|
||||
indoc! {"
|
||||
The quick
|
||||
brown fox
|
||||
jumps over
|
||||
the lˇazy"},
|
||||
["c", "g", "g"],
|
||||
)
|
||||
.await;
|
||||
cx.assert_neovim_compatible(
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"c g g",
|
||||
indoc! {"
|
||||
The qˇuick
|
||||
brown fox
|
||||
jumps over
|
||||
the lazy"},
|
||||
["c", "g", "g"],
|
||||
)
|
||||
.await;
|
||||
cx.assert_neovim_compatible(
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"c g g",
|
||||
indoc! {"
|
||||
ˇ
|
||||
brown fox
|
||||
jumps over
|
||||
the lazy"},
|
||||
["c", "g", "g"],
|
||||
)
|
||||
.await;
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
|
@ -499,8 +571,8 @@ mod test {
|
|||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
|
||||
for count in 1..=5 {
|
||||
cx.assert_binding_matches_all(
|
||||
["c", &count.to_string(), "j"],
|
||||
cx.simulate_at_each_offset(
|
||||
&format!("c {count} j"),
|
||||
indoc! {"
|
||||
ˇThe quˇickˇ browˇn
|
||||
ˇ
|
||||
|
@ -508,7 +580,8 @@ mod test {
|
|||
ˇthe lazy dog
|
||||
"},
|
||||
)
|
||||
.await;
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -517,8 +590,8 @@ mod test {
|
|||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
|
||||
for count in 1..=5 {
|
||||
cx.assert_binding_matches_all(
|
||||
["c", &count.to_string(), "l"],
|
||||
cx.simulate_at_each_offset(
|
||||
&format!("c {count} l"),
|
||||
indoc! {"
|
||||
ˇThe quˇickˇ browˇn
|
||||
ˇ
|
||||
|
@ -526,7 +599,8 @@ mod test {
|
|||
ˇthe lazy dog
|
||||
"},
|
||||
)
|
||||
.await;
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -535,16 +609,17 @@ mod test {
|
|||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
|
||||
for count in 1..=5 {
|
||||
for marked_text in cx.each_marked_position(indoc! {"
|
||||
cx.simulate_at_each_offset(
|
||||
&format!("c {count} b"),
|
||||
indoc! {"
|
||||
ˇThe quˇickˇ browˇn
|
||||
ˇ
|
||||
ˇfox ˇjumpsˇ-ˇoˇver
|
||||
ˇthe lazy dog
|
||||
"})
|
||||
{
|
||||
cx.assert_neovim_compatible(&marked_text, ["c", &count.to_string(), "b"])
|
||||
.await;
|
||||
}
|
||||
"},
|
||||
)
|
||||
.await
|
||||
.assert_matches()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -553,8 +628,8 @@ mod test {
|
|||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
|
||||
for count in 1..=5 {
|
||||
cx.assert_binding_matches_all(
|
||||
["c", &count.to_string(), "e"],
|
||||
cx.simulate_at_each_offset(
|
||||
&format!("c {count} e"),
|
||||
indoc! {"
|
||||
ˇThe quˇickˇ browˇn
|
||||
ˇ
|
||||
|
@ -562,7 +637,8 @@ mod test {
|
|||
ˇthe lazy dog
|
||||
"},
|
||||
)
|
||||
.await;
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -158,280 +158,358 @@ mod test {
|
|||
|
||||
use crate::{
|
||||
state::Mode,
|
||||
test::{ExemptionFeatures, NeovimBackedTestContext, VimTestContext},
|
||||
test::{NeovimBackedTestContext, VimTestContext},
|
||||
};
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_delete_h(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await.binding(["d", "h"]);
|
||||
cx.assert("Teˇst").await;
|
||||
cx.assert("Tˇest").await;
|
||||
cx.assert("ˇTest").await;
|
||||
cx.assert(indoc! {"
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.simulate("d h", "Teˇst").await.assert_matches();
|
||||
cx.simulate("d h", "Tˇest").await.assert_matches();
|
||||
cx.simulate("d h", "ˇTest").await.assert_matches();
|
||||
cx.simulate(
|
||||
"d h",
|
||||
indoc! {"
|
||||
Test
|
||||
ˇtest"})
|
||||
.await;
|
||||
ˇtest"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_delete_l(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await.binding(["d", "l"]);
|
||||
cx.assert("ˇTest").await;
|
||||
cx.assert("Teˇst").await;
|
||||
cx.assert("Tesˇt").await;
|
||||
cx.assert(indoc! {"
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.simulate("d l", "ˇTest").await.assert_matches();
|
||||
cx.simulate("d l", "Teˇst").await.assert_matches();
|
||||
cx.simulate("d l", "Tesˇt").await.assert_matches();
|
||||
cx.simulate(
|
||||
"d l",
|
||||
indoc! {"
|
||||
Tesˇt
|
||||
test"})
|
||||
.await;
|
||||
test"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_delete_w(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.assert_neovim_compatible(
|
||||
cx.simulate(
|
||||
"d w",
|
||||
indoc! {"
|
||||
Test tesˇt
|
||||
test"},
|
||||
["d", "w"],
|
||||
)
|
||||
.await;
|
||||
.await
|
||||
.assert_matches();
|
||||
|
||||
cx.assert_neovim_compatible("Teˇst", ["d", "w"]).await;
|
||||
cx.assert_neovim_compatible("Tˇest test", ["d", "w"]).await;
|
||||
cx.assert_neovim_compatible(
|
||||
cx.simulate("d w", "Teˇst").await.assert_matches();
|
||||
cx.simulate("d w", "Tˇest test").await.assert_matches();
|
||||
cx.simulate(
|
||||
"d w",
|
||||
indoc! {"
|
||||
Test teˇst
|
||||
test"},
|
||||
["d", "w"],
|
||||
)
|
||||
.await;
|
||||
cx.assert_neovim_compatible(
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"d w",
|
||||
indoc! {"
|
||||
Test tesˇt
|
||||
test"},
|
||||
["d", "w"],
|
||||
)
|
||||
.await;
|
||||
.await
|
||||
.assert_matches();
|
||||
|
||||
cx.assert_neovim_compatible(
|
||||
cx.simulate(
|
||||
"d w",
|
||||
indoc! {"
|
||||
Test test
|
||||
ˇ
|
||||
test"},
|
||||
["d", "w"],
|
||||
)
|
||||
.await;
|
||||
.await
|
||||
.assert_matches();
|
||||
|
||||
let mut cx = cx.binding(["d", "shift-w"]);
|
||||
cx.assert_neovim_compatible("Test teˇst-test test", ["d", "shift-w"])
|
||||
.await;
|
||||
cx.simulate("d shift-w", "Test teˇst-test test")
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_delete_next_word_end(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await.binding(["d", "e"]);
|
||||
// cx.assert("Teˇst Test").await;
|
||||
// cx.assert("Tˇest test").await;
|
||||
cx.assert(indoc! {"
|
||||
Test teˇst
|
||||
test"})
|
||||
.await;
|
||||
cx.assert(indoc! {"
|
||||
Test tesˇt
|
||||
test"})
|
||||
.await;
|
||||
cx.assert_exempted(
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.simulate("d e", "Teˇst Test\n").await.assert_matches();
|
||||
cx.simulate("d e", "Tˇest test\n").await.assert_matches();
|
||||
cx.simulate(
|
||||
"d e",
|
||||
indoc! {"
|
||||
Test test
|
||||
ˇ
|
||||
Test teˇst
|
||||
test"},
|
||||
ExemptionFeatures::OperatorLastNewlineRemains,
|
||||
)
|
||||
.await;
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"d e",
|
||||
indoc! {"
|
||||
Test tesˇt
|
||||
test"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
|
||||
let mut cx = cx.binding(["d", "shift-e"]);
|
||||
cx.assert("Test teˇst-test test").await;
|
||||
cx.simulate("d e", "Test teˇst-test test")
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_delete_b(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await.binding(["d", "b"]);
|
||||
cx.assert("Teˇst Test").await;
|
||||
cx.assert("Test ˇtest").await;
|
||||
cx.assert("Test1 test2 ˇtest3").await;
|
||||
cx.assert(indoc! {"
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.simulate("d b", "Teˇst Test").await.assert_matches();
|
||||
cx.simulate("d b", "Test ˇtest").await.assert_matches();
|
||||
cx.simulate("d b", "Test1 test2 ˇtest3")
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"d b",
|
||||
indoc! {"
|
||||
Test test
|
||||
ˇtest"})
|
||||
.await;
|
||||
cx.assert(indoc! {"
|
||||
ˇtest"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"d b",
|
||||
indoc! {"
|
||||
Test test
|
||||
ˇ
|
||||
test"})
|
||||
.await;
|
||||
test"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
|
||||
let mut cx = cx.binding(["d", "shift-b"]);
|
||||
cx.assert("Test test-test ˇtest").await;
|
||||
cx.simulate("d shift-b", "Test test-test ˇtest")
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_delete_end_of_line(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await.binding(["d", "$"]);
|
||||
cx.assert(indoc! {"
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.simulate(
|
||||
"d $",
|
||||
indoc! {"
|
||||
The qˇuick
|
||||
brown fox"})
|
||||
.await;
|
||||
cx.assert(indoc! {"
|
||||
brown fox"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"d $",
|
||||
indoc! {"
|
||||
The quick
|
||||
ˇ
|
||||
brown fox"})
|
||||
.await;
|
||||
brown fox"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_delete_0(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await.binding(["d", "0"]);
|
||||
cx.assert(indoc! {"
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.simulate(
|
||||
"d 0",
|
||||
indoc! {"
|
||||
The qˇuick
|
||||
brown fox"})
|
||||
.await;
|
||||
cx.assert(indoc! {"
|
||||
brown fox"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"d 0",
|
||||
indoc! {"
|
||||
The quick
|
||||
ˇ
|
||||
brown fox"})
|
||||
.await;
|
||||
brown fox"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_delete_k(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await.binding(["d", "k"]);
|
||||
cx.assert(indoc! {"
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.simulate(
|
||||
"d k",
|
||||
indoc! {"
|
||||
The quick
|
||||
brown ˇfox
|
||||
jumps over"})
|
||||
.await;
|
||||
cx.assert(indoc! {"
|
||||
jumps over"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"d k",
|
||||
indoc! {"
|
||||
The quick
|
||||
brown fox
|
||||
jumps ˇover"})
|
||||
.await;
|
||||
cx.assert(indoc! {"
|
||||
jumps ˇover"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"d k",
|
||||
indoc! {"
|
||||
The qˇuick
|
||||
brown fox
|
||||
jumps over"})
|
||||
.await;
|
||||
cx.assert(indoc! {"
|
||||
jumps over"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"d k",
|
||||
indoc! {"
|
||||
ˇbrown fox
|
||||
jumps over"})
|
||||
.await;
|
||||
jumps over"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_delete_j(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await.binding(["d", "j"]);
|
||||
cx.assert(indoc! {"
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.simulate(
|
||||
"d j",
|
||||
indoc! {"
|
||||
The quick
|
||||
brown ˇfox
|
||||
jumps over"})
|
||||
.await;
|
||||
cx.assert(indoc! {"
|
||||
jumps over"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"d j",
|
||||
indoc! {"
|
||||
The quick
|
||||
brown fox
|
||||
jumps ˇover"})
|
||||
.await;
|
||||
cx.assert(indoc! {"
|
||||
jumps ˇover"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"d j",
|
||||
indoc! {"
|
||||
The qˇuick
|
||||
brown fox
|
||||
jumps over"})
|
||||
.await;
|
||||
cx.assert(indoc! {"
|
||||
jumps over"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"d j",
|
||||
indoc! {"
|
||||
The quick
|
||||
brown fox
|
||||
ˇ"})
|
||||
.await;
|
||||
ˇ"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_delete_end_of_document(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.assert_neovim_compatible(
|
||||
cx.simulate(
|
||||
"d shift-g",
|
||||
indoc! {"
|
||||
The quick
|
||||
brownˇ fox
|
||||
jumps over
|
||||
the lazy"},
|
||||
["d", "shift-g"],
|
||||
)
|
||||
.await;
|
||||
cx.assert_neovim_compatible(
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"d shift-g",
|
||||
indoc! {"
|
||||
The quick
|
||||
brownˇ fox
|
||||
jumps over
|
||||
the lazy"},
|
||||
["d", "shift-g"],
|
||||
)
|
||||
.await;
|
||||
cx.assert_neovim_compatible(
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"d shift-g",
|
||||
indoc! {"
|
||||
The quick
|
||||
brown fox
|
||||
jumps over
|
||||
the lˇazy"},
|
||||
["d", "shift-g"],
|
||||
)
|
||||
.await;
|
||||
cx.assert_neovim_compatible(
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"d shift-g",
|
||||
indoc! {"
|
||||
The quick
|
||||
brown fox
|
||||
jumps over
|
||||
ˇ"},
|
||||
["d", "shift-g"],
|
||||
)
|
||||
.await;
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_delete_gg(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx)
|
||||
.await
|
||||
.binding(["d", "g", "g"]);
|
||||
cx.assert_neovim_compatible(
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.simulate(
|
||||
"d g g",
|
||||
indoc! {"
|
||||
The quick
|
||||
brownˇ fox
|
||||
jumps over
|
||||
the lazy"},
|
||||
["d", "g", "g"],
|
||||
)
|
||||
.await;
|
||||
cx.assert_neovim_compatible(
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"d g g",
|
||||
indoc! {"
|
||||
The quick
|
||||
brown fox
|
||||
jumps over
|
||||
the lˇazy"},
|
||||
["d", "g", "g"],
|
||||
)
|
||||
.await;
|
||||
cx.assert_neovim_compatible(
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"d g g",
|
||||
indoc! {"
|
||||
The qˇuick
|
||||
brown fox
|
||||
jumps over
|
||||
the lazy"},
|
||||
["d", "g", "g"],
|
||||
)
|
||||
.await;
|
||||
cx.assert_neovim_compatible(
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"d g g",
|
||||
indoc! {"
|
||||
ˇ
|
||||
brown fox
|
||||
jumps over
|
||||
the lazy"},
|
||||
["d", "g", "g"],
|
||||
)
|
||||
.await;
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
|
@ -446,7 +524,7 @@ mod test {
|
|||
);
|
||||
|
||||
// Canceling operator twice reverts to normal mode with no active operator
|
||||
cx.simulate_keystrokes(["d", "escape", "k"]);
|
||||
cx.simulate_keystrokes("d escape k");
|
||||
assert_eq!(cx.active_operator(), None);
|
||||
assert_eq!(cx.mode(), Mode::Normal);
|
||||
cx.assert_editor_state(indoc! {"
|
||||
|
@ -467,7 +545,7 @@ mod test {
|
|||
);
|
||||
|
||||
// Canceling operator twice reverts to normal mode with no active operator
|
||||
cx.simulate_keystrokes(["d", "y"]);
|
||||
cx.simulate_keystrokes("d y");
|
||||
assert_eq!(cx.active_operator(), None);
|
||||
assert_eq!(cx.mode(), Mode::Normal);
|
||||
}
|
||||
|
@ -480,20 +558,18 @@ mod test {
|
|||
fox jumps over
|
||||
the lazy dog"})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["d", "2", "d"]).await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
the ˇlazy dog"})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes("d 2 d").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
the ˇlazy dog"});
|
||||
|
||||
cx.set_shared_state(indoc! {"
|
||||
The ˇquick brown
|
||||
fox jumps over
|
||||
the lazy dog"})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["2", "d", "d"]).await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
the ˇlazy dog"})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes("2 d d").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
the ˇlazy dog"});
|
||||
|
||||
cx.set_shared_state(indoc! {"
|
||||
The ˇquick brown
|
||||
|
@ -502,16 +578,15 @@ mod test {
|
|||
a star, and
|
||||
the lazy dog"})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["2", "d", "2", "d"]).await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
the ˇlazy dog"})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes("2 d 2 d").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
the ˇlazy dog"});
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_delete_to_adjacent_character(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.assert_neovim_compatible("ˇax", ["d", "t", "x"]).await;
|
||||
cx.assert_neovim_compatible("aˇx", ["d", "t", "x"]).await;
|
||||
cx.simulate("d t x", "ˇax").await.assert_matches();
|
||||
cx.simulate("d t x", "aˇx").await.assert_matches();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -191,33 +191,27 @@ mod test {
|
|||
"})
|
||||
.await;
|
||||
|
||||
cx.simulate_shared_keystrokes(["ctrl-a"]).await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
cx.simulate_shared_keystrokes("ctrl-a").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
1ˇ3
|
||||
"})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["ctrl-x"]).await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
"});
|
||||
cx.simulate_shared_keystrokes("ctrl-x").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
1ˇ2
|
||||
"})
|
||||
.await;
|
||||
"});
|
||||
|
||||
cx.simulate_shared_keystrokes(["9", "9", "ctrl-a"]).await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
cx.simulate_shared_keystrokes("9 9 ctrl-a").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
11ˇ1
|
||||
"})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["1", "1", "1", "ctrl-x"])
|
||||
.await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
"});
|
||||
cx.simulate_shared_keystrokes("1 1 1 ctrl-x").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
ˇ0
|
||||
"})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["."]).await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
"});
|
||||
cx.simulate_shared_keystrokes(".").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
-11ˇ1
|
||||
"})
|
||||
.await;
|
||||
"});
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
|
@ -229,16 +223,14 @@ mod test {
|
|||
"})
|
||||
.await;
|
||||
|
||||
cx.simulate_shared_keystrokes(["ctrl-a"]).await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
cx.simulate_shared_keystrokes("ctrl-a").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
1.ˇ3
|
||||
"})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["ctrl-x"]).await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
"});
|
||||
cx.simulate_shared_keystrokes("ctrl-x").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
1.ˇ2
|
||||
"})
|
||||
.await;
|
||||
"});
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
|
@ -250,33 +242,32 @@ mod test {
|
|||
"})
|
||||
.await;
|
||||
|
||||
cx.simulate_shared_keystrokes(["ctrl-a"]).await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
cx.simulate_shared_keystrokes("ctrl-a").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
111..ˇ3
|
||||
"})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["ctrl-x"]).await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
"});
|
||||
cx.simulate_shared_keystrokes("ctrl-x").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
111..ˇ2
|
||||
"})
|
||||
.await;
|
||||
"});
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_increment_radix(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
|
||||
cx.assert_matches_neovim("ˇ total: 0xff", ["ctrl-a"], " total: 0x10ˇ0")
|
||||
.await;
|
||||
cx.assert_matches_neovim("ˇ total: 0xff", ["ctrl-x"], " total: 0xfˇe")
|
||||
.await;
|
||||
cx.assert_matches_neovim("ˇ total: 0xFF", ["ctrl-x"], " total: 0xFˇE")
|
||||
.await;
|
||||
cx.assert_matches_neovim("(ˇ0b10f)", ["ctrl-a"], "(0b1ˇ1f)")
|
||||
.await;
|
||||
cx.assert_matches_neovim("ˇ-1", ["ctrl-a"], "ˇ0").await;
|
||||
cx.assert_matches_neovim("banˇana", ["ctrl-a"], "banˇana")
|
||||
.await;
|
||||
cx.simulate("ctrl-a", "ˇ total: 0xff")
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate("ctrl-x", "ˇ total: 0xff")
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate("ctrl-x", "ˇ total: 0xFF")
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate("ctrl-a", "(ˇ0b10f)").await.assert_matches();
|
||||
cx.simulate("ctrl-a", "ˇ-1").await.assert_matches();
|
||||
cx.simulate("ctrl-a", "banˇana").await.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
|
@ -291,33 +282,28 @@ mod test {
|
|||
1"})
|
||||
.await;
|
||||
|
||||
cx.simulate_shared_keystrokes(["j", "v", "shift-g", "g", "ctrl-a"])
|
||||
.await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
cx.simulate_shared_keystrokes("j v shift-g g ctrl-a").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
1
|
||||
ˇ2
|
||||
3 2
|
||||
4
|
||||
5"})
|
||||
.await;
|
||||
5"});
|
||||
|
||||
cx.simulate_shared_keystrokes(["shift-g", "ctrl-v", "g", "g"])
|
||||
.await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
cx.simulate_shared_keystrokes("shift-g ctrl-v g g").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
«1ˇ»
|
||||
«2ˇ»
|
||||
«3ˇ» 2
|
||||
«4ˇ»
|
||||
«5ˇ»"})
|
||||
.await;
|
||||
«5ˇ»"});
|
||||
|
||||
cx.simulate_shared_keystrokes(["g", "ctrl-x"]).await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
cx.simulate_shared_keystrokes("g ctrl-x").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
ˇ0
|
||||
0
|
||||
0 2
|
||||
0
|
||||
0"})
|
||||
.await;
|
||||
0"});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -246,31 +246,29 @@ mod test {
|
|||
fox ˇjumps over
|
||||
the lazy dog"})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["v", "w", "y"]).await;
|
||||
cx.assert_shared_clipboard("jumps o").await;
|
||||
cx.simulate_shared_keystrokes("v w y").await;
|
||||
cx.shared_clipboard().await.assert_eq("jumps o");
|
||||
cx.set_shared_state(indoc! {"
|
||||
The quick brown
|
||||
fox jumps oveˇr
|
||||
the lazy dog"})
|
||||
.await;
|
||||
cx.simulate_shared_keystroke("p").await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
cx.simulate_shared_keystrokes("p").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
The quick brown
|
||||
fox jumps overjumps ˇo
|
||||
the lazy dog"})
|
||||
.await;
|
||||
the lazy dog"});
|
||||
|
||||
cx.set_shared_state(indoc! {"
|
||||
The quick brown
|
||||
fox jumps oveˇr
|
||||
the lazy dog"})
|
||||
.await;
|
||||
cx.simulate_shared_keystroke("shift-p").await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
cx.simulate_shared_keystrokes("shift-p").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
The quick brown
|
||||
fox jumps ovejumps ˇor
|
||||
the lazy dog"})
|
||||
.await;
|
||||
the lazy dog"});
|
||||
|
||||
// line mode
|
||||
cx.set_shared_state(indoc! {"
|
||||
|
@ -278,25 +276,22 @@ mod test {
|
|||
fox juˇmps over
|
||||
the lazy dog"})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["d", "d"]).await;
|
||||
cx.assert_shared_clipboard("fox jumps over\n").await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
cx.simulate_shared_keystrokes("d d").await;
|
||||
cx.shared_clipboard().await.assert_eq("fox jumps over\n");
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
The quick brown
|
||||
the laˇzy dog"})
|
||||
.await;
|
||||
cx.simulate_shared_keystroke("p").await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
the laˇzy dog"});
|
||||
cx.simulate_shared_keystrokes("p").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
The quick brown
|
||||
the lazy dog
|
||||
ˇfox jumps over"})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["k", "shift-p"]).await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
ˇfox jumps over"});
|
||||
cx.simulate_shared_keystrokes("k shift-p").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
The quick brown
|
||||
ˇfox jumps over
|
||||
the lazy dog
|
||||
fox jumps over"})
|
||||
.await;
|
||||
fox jumps over"});
|
||||
|
||||
// multiline, cursor to first character of pasted text.
|
||||
cx.set_shared_state(indoc! {"
|
||||
|
@ -304,23 +299,21 @@ mod test {
|
|||
fox jumps ˇover
|
||||
the lazy dog"})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["v", "j", "y"]).await;
|
||||
cx.assert_shared_clipboard("over\nthe lazy do").await;
|
||||
cx.simulate_shared_keystrokes("v j y").await;
|
||||
cx.shared_clipboard().await.assert_eq("over\nthe lazy do");
|
||||
|
||||
cx.simulate_shared_keystroke("p").await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
cx.simulate_shared_keystrokes("p").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
The quick brown
|
||||
fox jumps oˇover
|
||||
the lazy dover
|
||||
the lazy dog"})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["u", "shift-p"]).await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
the lazy dog"});
|
||||
cx.simulate_shared_keystrokes("u shift-p").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
The quick brown
|
||||
fox jumps ˇover
|
||||
the lazy doover
|
||||
the lazy dog"})
|
||||
.await;
|
||||
the lazy dog"});
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
|
@ -340,7 +333,7 @@ mod test {
|
|||
the lazy dog"},
|
||||
Mode::Normal,
|
||||
);
|
||||
cx.simulate_keystrokes(["v", "i", "w", "y"]);
|
||||
cx.simulate_keystrokes("v i w y");
|
||||
cx.assert_state(
|
||||
indoc! {"
|
||||
The quick brown
|
||||
|
@ -348,7 +341,7 @@ mod test {
|
|||
the lazy dog"},
|
||||
Mode::Normal,
|
||||
);
|
||||
cx.simulate_keystroke("p");
|
||||
cx.simulate_keystrokes("p");
|
||||
cx.assert_state(
|
||||
indoc! {"
|
||||
The quick brown
|
||||
|
@ -377,7 +370,7 @@ mod test {
|
|||
the lazy dog"},
|
||||
Mode::Normal,
|
||||
);
|
||||
cx.simulate_keystrokes(["v", "i", "w", "y"]);
|
||||
cx.simulate_keystrokes("v i w y");
|
||||
cx.assert_state(
|
||||
indoc! {"
|
||||
The quick brown
|
||||
|
@ -385,7 +378,7 @@ mod test {
|
|||
the lazy dog"},
|
||||
Mode::Normal,
|
||||
);
|
||||
cx.simulate_keystroke("p");
|
||||
cx.simulate_keystrokes("p");
|
||||
cx.assert_state(
|
||||
indoc! {"
|
||||
The quick brown
|
||||
|
@ -397,7 +390,7 @@ mod test {
|
|||
cx.read_from_clipboard().map(|item| item.text().clone()),
|
||||
Some("jumps".into())
|
||||
);
|
||||
cx.simulate_keystrokes(["d", "d", "p"]);
|
||||
cx.simulate_keystrokes("d d p");
|
||||
cx.assert_state(
|
||||
indoc! {"
|
||||
The quick brown
|
||||
|
@ -410,7 +403,7 @@ mod test {
|
|||
Some("jumps".into())
|
||||
);
|
||||
cx.write_to_clipboard(ClipboardItem::new("test-copy".to_string()));
|
||||
cx.simulate_keystroke("shift-p");
|
||||
cx.simulate_keystrokes("shift-p");
|
||||
cx.assert_state(
|
||||
indoc! {"
|
||||
The quick brown
|
||||
|
@ -430,38 +423,31 @@ mod test {
|
|||
fox jˇumps over
|
||||
the lazy dog"})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["v", "i", "w", "y"]).await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
cx.simulate_shared_keystrokes("v i w y").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
The quick brown
|
||||
fox ˇjumps over
|
||||
the lazy dog"})
|
||||
.await;
|
||||
the lazy dog"});
|
||||
// paste in visual mode
|
||||
cx.simulate_shared_keystrokes(["w", "v", "i", "w", "p"])
|
||||
.await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
cx.simulate_shared_keystrokes("w v i w p").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
The quick brown
|
||||
fox jumps jumpˇs
|
||||
the lazy dog"})
|
||||
.await;
|
||||
cx.assert_shared_clipboard("over").await;
|
||||
the lazy dog"});
|
||||
cx.shared_clipboard().await.assert_eq("over");
|
||||
// paste in visual line mode
|
||||
cx.simulate_shared_keystrokes(["up", "shift-v", "shift-p"])
|
||||
.await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
cx.simulate_shared_keystrokes("up shift-v shift-p").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
ˇover
|
||||
fox jumps jumps
|
||||
the lazy dog"})
|
||||
.await;
|
||||
cx.assert_shared_clipboard("over").await;
|
||||
the lazy dog"});
|
||||
cx.shared_clipboard().await.assert_eq("over");
|
||||
// paste in visual block mode
|
||||
cx.simulate_shared_keystrokes(["ctrl-v", "down", "down", "p"])
|
||||
.await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
cx.simulate_shared_keystrokes("ctrl-v down down p").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
oveˇrver
|
||||
overox jumps jumps
|
||||
overhe lazy dog"})
|
||||
.await;
|
||||
overhe lazy dog"});
|
||||
|
||||
// copy in visual line mode
|
||||
cx.set_shared_state(indoc! {"
|
||||
|
@ -469,40 +455,33 @@ mod test {
|
|||
fox juˇmps over
|
||||
the lazy dog"})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["shift-v", "d"]).await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
cx.simulate_shared_keystrokes("shift-v d").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
The quick brown
|
||||
the laˇzy dog"})
|
||||
.await;
|
||||
the laˇzy dog"});
|
||||
// paste in visual mode
|
||||
cx.simulate_shared_keystrokes(["v", "i", "w", "p"]).await;
|
||||
cx.assert_shared_state(
|
||||
&indoc! {"
|
||||
cx.simulate_shared_keystrokes("v i w p").await;
|
||||
cx.shared_state().await.assert_eq(&indoc! {"
|
||||
The quick brown
|
||||
the_
|
||||
the•
|
||||
ˇfox jumps over
|
||||
_dog"}
|
||||
.replace('_', " "), // Hack for trailing whitespace
|
||||
)
|
||||
.await;
|
||||
cx.assert_shared_clipboard("lazy").await;
|
||||
dog"});
|
||||
cx.shared_clipboard().await.assert_eq("lazy");
|
||||
cx.set_shared_state(indoc! {"
|
||||
The quick brown
|
||||
fox juˇmps over
|
||||
the lazy dog"})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["shift-v", "d"]).await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
cx.simulate_shared_keystrokes("shift-v d").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
The quick brown
|
||||
the laˇzy dog"})
|
||||
.await;
|
||||
the laˇzy dog"});
|
||||
// paste in visual line mode
|
||||
cx.simulate_shared_keystrokes(["k", "shift-v", "p"]).await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
cx.simulate_shared_keystrokes("k shift-v p").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
ˇfox jumps over
|
||||
the lazy dog"})
|
||||
.await;
|
||||
cx.assert_shared_clipboard("The quick brown\n").await;
|
||||
the lazy dog"});
|
||||
cx.shared_clipboard().await.assert_eq("The quick brown\n");
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
|
@ -514,47 +493,39 @@ mod test {
|
|||
fox jumps over
|
||||
the lazy dog"})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["ctrl-v", "2", "j", "y"])
|
||||
.await;
|
||||
cx.assert_shared_clipboard("q\nj\nl").await;
|
||||
cx.simulate_shared_keystrokes(["p"]).await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
cx.simulate_shared_keystrokes("ctrl-v 2 j y").await;
|
||||
cx.shared_clipboard().await.assert_eq("q\nj\nl");
|
||||
cx.simulate_shared_keystrokes("p").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
The qˇquick brown
|
||||
fox jjumps over
|
||||
the llazy dog"})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["v", "i", "w", "shift-p"])
|
||||
.await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
the llazy dog"});
|
||||
cx.simulate_shared_keystrokes("v i w shift-p").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
The ˇq brown
|
||||
fox jjjumps over
|
||||
the lllazy dog"})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["v", "i", "w", "shift-p"])
|
||||
.await;
|
||||
the lllazy dog"});
|
||||
cx.simulate_shared_keystrokes("v i w shift-p").await;
|
||||
|
||||
cx.set_shared_state(indoc! {"
|
||||
The ˇquick brown
|
||||
fox jumps over
|
||||
the lazy dog"})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["ctrl-v", "j", "y"]).await;
|
||||
cx.assert_shared_clipboard("q\nj").await;
|
||||
cx.simulate_shared_keystrokes(["l", "ctrl-v", "2", "j", "shift-p"])
|
||||
.await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
cx.simulate_shared_keystrokes("ctrl-v j y").await;
|
||||
cx.shared_clipboard().await.assert_eq("q\nj");
|
||||
cx.simulate_shared_keystrokes("l ctrl-v 2 j shift-p").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
The qˇqick brown
|
||||
fox jjmps over
|
||||
the lzy dog"})
|
||||
.await;
|
||||
the lzy dog"});
|
||||
|
||||
cx.simulate_shared_keystrokes(["shift-v", "p"]).await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
cx.simulate_shared_keystrokes("shift-v p").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
ˇq
|
||||
j
|
||||
fox jjmps over
|
||||
the lzy dog"})
|
||||
.await;
|
||||
the lzy dog"});
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
|
@ -568,7 +539,7 @@ mod test {
|
|||
"},
|
||||
Mode::Normal,
|
||||
);
|
||||
cx.simulate_keystrokes(["o", "a", "(", ")", "{", "escape"]);
|
||||
cx.simulate_keystrokes("o a ( ) { escape");
|
||||
cx.assert_state(
|
||||
indoc! {"
|
||||
class A {
|
||||
|
@ -578,7 +549,7 @@ mod test {
|
|||
Mode::Normal,
|
||||
);
|
||||
// cursor goes to the first non-blank character in the line;
|
||||
cx.simulate_keystrokes(["y", "y", "p"]);
|
||||
cx.simulate_keystrokes("y y p");
|
||||
cx.assert_state(
|
||||
indoc! {"
|
||||
class A {
|
||||
|
@ -589,7 +560,7 @@ mod test {
|
|||
Mode::Normal,
|
||||
);
|
||||
// indentation is preserved when pasting
|
||||
cx.simulate_keystrokes(["u", "shift-v", "up", "y", "shift-p"]);
|
||||
cx.simulate_keystrokes("u shift-v up y shift-p");
|
||||
cx.assert_state(
|
||||
indoc! {"
|
||||
ˇclass A {
|
||||
|
@ -612,16 +583,15 @@ mod test {
|
|||
three
|
||||
"})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["y", "y", "3", "p"]).await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
cx.simulate_shared_keystrokes("y y 3 p").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
one
|
||||
ˇone
|
||||
one
|
||||
one
|
||||
two
|
||||
three
|
||||
"})
|
||||
.await;
|
||||
"});
|
||||
|
||||
cx.set_shared_state(indoc! {"
|
||||
one
|
||||
|
@ -629,13 +599,11 @@ mod test {
|
|||
three
|
||||
"})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["y", "$", "$", "3", "p"])
|
||||
.await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
cx.simulate_shared_keystrokes("y $ $ 3 p").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
one
|
||||
twotwotwotwˇo
|
||||
three
|
||||
"})
|
||||
.await;
|
||||
"});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -222,32 +222,32 @@ mod test {
|
|||
|
||||
// "o"
|
||||
cx.set_shared_state("ˇhello").await;
|
||||
cx.simulate_shared_keystrokes(["o", "w", "o", "r", "l", "d", "escape"])
|
||||
.await;
|
||||
cx.assert_shared_state("hello\nworlˇd").await;
|
||||
cx.simulate_shared_keystrokes(["."]).await;
|
||||
cx.assert_shared_state("hello\nworld\nworlˇd").await;
|
||||
cx.simulate_shared_keystrokes("o w o r l d escape").await;
|
||||
cx.shared_state().await.assert_eq("hello\nworlˇd");
|
||||
cx.simulate_shared_keystrokes(".").await;
|
||||
cx.shared_state().await.assert_eq("hello\nworld\nworlˇd");
|
||||
|
||||
// "d"
|
||||
cx.simulate_shared_keystrokes(["^", "d", "f", "o"]).await;
|
||||
cx.simulate_shared_keystrokes(["g", "g", "."]).await;
|
||||
cx.assert_shared_state("ˇ\nworld\nrld").await;
|
||||
cx.simulate_shared_keystrokes("^ d f o").await;
|
||||
cx.simulate_shared_keystrokes("g g .").await;
|
||||
cx.shared_state().await.assert_eq("ˇ\nworld\nrld");
|
||||
|
||||
// "p" (note that it pastes the current clipboard)
|
||||
cx.simulate_shared_keystrokes(["j", "y", "y", "p"]).await;
|
||||
cx.simulate_shared_keystrokes(["shift-g", "y", "y", "."])
|
||||
.await;
|
||||
cx.assert_shared_state("\nworld\nworld\nrld\nˇrld").await;
|
||||
cx.simulate_shared_keystrokes("j y y p").await;
|
||||
cx.simulate_shared_keystrokes("shift-g y y .").await;
|
||||
cx.shared_state()
|
||||
.await
|
||||
.assert_eq("\nworld\nworld\nrld\nˇrld");
|
||||
|
||||
// "~" (note that counts apply to the action taken, not . itself)
|
||||
cx.set_shared_state("ˇthe quick brown fox").await;
|
||||
cx.simulate_shared_keystrokes(["2", "~", "."]).await;
|
||||
cx.simulate_shared_keystrokes("2 ~ .").await;
|
||||
cx.set_shared_state("THE ˇquick brown fox").await;
|
||||
cx.simulate_shared_keystrokes(["3", "."]).await;
|
||||
cx.simulate_shared_keystrokes("3 .").await;
|
||||
cx.set_shared_state("THE QUIˇck brown fox").await;
|
||||
cx.run_until_parked();
|
||||
cx.simulate_shared_keystrokes(["."]).await;
|
||||
cx.assert_shared_state("THE QUICK ˇbrown fox").await;
|
||||
cx.simulate_shared_keystrokes(".").await;
|
||||
cx.shared_state().await.assert_eq("THE QUICK ˇbrown fox");
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
|
@ -255,16 +255,16 @@ mod test {
|
|||
let mut cx = VimTestContext::new(cx, true).await;
|
||||
|
||||
cx.set_state("hˇllo", Mode::Normal);
|
||||
cx.simulate_keystrokes(["i"]);
|
||||
cx.simulate_keystrokes("i");
|
||||
|
||||
// simulate brazilian input for ä.
|
||||
cx.update_editor(|editor, cx| {
|
||||
editor.replace_and_mark_text_in_range(None, "\"", Some(1..1), cx);
|
||||
editor.replace_text_in_range(None, "ä", cx);
|
||||
});
|
||||
cx.simulate_keystrokes(["escape"]);
|
||||
cx.simulate_keystrokes("escape");
|
||||
cx.assert_state("hˇällo", Mode::Normal);
|
||||
cx.simulate_keystrokes(["."]);
|
||||
cx.simulate_keystrokes(".");
|
||||
cx.assert_state("hˇäällo", Mode::Normal);
|
||||
}
|
||||
|
||||
|
@ -316,11 +316,11 @@ mod test {
|
|||
},
|
||||
])))
|
||||
});
|
||||
cx.simulate_keystrokes(["a", "."]);
|
||||
cx.simulate_keystrokes("a .");
|
||||
request.next().await;
|
||||
cx.condition(|editor, _| editor.context_menu_visible())
|
||||
.await;
|
||||
cx.simulate_keystrokes(["down", "enter", "!", "escape"]);
|
||||
cx.simulate_keystrokes("down enter ! escape");
|
||||
|
||||
cx.assert_state(
|
||||
indoc! {"
|
||||
|
@ -330,7 +330,7 @@ mod test {
|
|||
"},
|
||||
Mode::Normal,
|
||||
);
|
||||
cx.simulate_keystrokes(["j", "."]);
|
||||
cx.simulate_keystrokes("j .");
|
||||
cx.assert_state(
|
||||
indoc! {"
|
||||
one.second!
|
||||
|
@ -352,27 +352,23 @@ mod test {
|
|||
the lazy dog"
|
||||
})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["v", "i", "w", "s", "o", "escape"])
|
||||
.await;
|
||||
cx.assert_shared_state(indoc! {
|
||||
cx.simulate_shared_keystrokes("v i w s o escape").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {
|
||||
"ˇo quick brown
|
||||
fox jumps over
|
||||
the lazy dog"
|
||||
})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["j", "w", "."]).await;
|
||||
cx.assert_shared_state(indoc! {
|
||||
});
|
||||
cx.simulate_shared_keystrokes("j w .").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {
|
||||
"o quick brown
|
||||
fox ˇops over
|
||||
the lazy dog"
|
||||
})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["f", "r", "."]).await;
|
||||
cx.assert_shared_state(indoc! {
|
||||
});
|
||||
cx.simulate_shared_keystrokes("f r .").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {
|
||||
"o quick brown
|
||||
fox ops oveˇothe lazy dog"
|
||||
})
|
||||
.await;
|
||||
});
|
||||
|
||||
// visual
|
||||
cx.set_shared_state(indoc! {
|
||||
|
@ -383,33 +379,29 @@ mod test {
|
|||
the lazy dog"
|
||||
})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["v", "j", "x"]).await;
|
||||
cx.assert_shared_state(indoc! {
|
||||
cx.simulate_shared_keystrokes("v j x").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {
|
||||
"the ˇumps over
|
||||
fox jumps over
|
||||
fox jumps over
|
||||
the lazy dog"
|
||||
})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["."]).await;
|
||||
cx.assert_shared_state(indoc! {
|
||||
});
|
||||
cx.simulate_shared_keystrokes(".").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {
|
||||
"the ˇumps over
|
||||
fox jumps over
|
||||
the lazy dog"
|
||||
})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["w", "."]).await;
|
||||
cx.assert_shared_state(indoc! {
|
||||
});
|
||||
cx.simulate_shared_keystrokes("w .").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {
|
||||
"the umps ˇumps over
|
||||
the lazy dog"
|
||||
})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["j", "."]).await;
|
||||
cx.assert_shared_state(indoc! {
|
||||
});
|
||||
cx.simulate_shared_keystrokes("j .").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {
|
||||
"the umps umps over
|
||||
the ˇog"
|
||||
})
|
||||
.await;
|
||||
});
|
||||
|
||||
// block mode (3 rows)
|
||||
cx.set_shared_state(indoc! {
|
||||
|
@ -418,21 +410,19 @@ mod test {
|
|||
the lazy dog"
|
||||
})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["ctrl-v", "j", "j", "shift-i", "o", "escape"])
|
||||
cx.simulate_shared_keystrokes("ctrl-v j j shift-i o escape")
|
||||
.await;
|
||||
cx.assert_shared_state(indoc! {
|
||||
cx.shared_state().await.assert_eq(indoc! {
|
||||
"ˇothe quick brown
|
||||
ofox jumps over
|
||||
othe lazy dog"
|
||||
})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["j", "4", "l", "."]).await;
|
||||
cx.assert_shared_state(indoc! {
|
||||
});
|
||||
cx.simulate_shared_keystrokes("j 4 l .").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {
|
||||
"othe quick brown
|
||||
ofoxˇo jumps over
|
||||
otheo lazy dog"
|
||||
})
|
||||
.await;
|
||||
});
|
||||
|
||||
// line mode
|
||||
cx.set_shared_state(indoc! {
|
||||
|
@ -441,21 +431,19 @@ mod test {
|
|||
the lazy dog"
|
||||
})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["shift-v", "shift-r", "o", "escape"])
|
||||
cx.simulate_shared_keystrokes("shift-v shift-r o escape")
|
||||
.await;
|
||||
cx.assert_shared_state(indoc! {
|
||||
cx.shared_state().await.assert_eq(indoc! {
|
||||
"ˇo
|
||||
fox jumps over
|
||||
the lazy dog"
|
||||
})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["j", "."]).await;
|
||||
cx.assert_shared_state(indoc! {
|
||||
});
|
||||
cx.simulate_shared_keystrokes("j .").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {
|
||||
"o
|
||||
ˇo
|
||||
the lazy dog"
|
||||
})
|
||||
.await;
|
||||
});
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
|
@ -468,27 +456,24 @@ mod test {
|
|||
the lazy dog"
|
||||
})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["3", "d", "3", "l"]).await;
|
||||
cx.assert_shared_state(indoc! {
|
||||
cx.simulate_shared_keystrokes("3 d 3 l").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {
|
||||
"ˇ brown
|
||||
fox jumps over
|
||||
the lazy dog"
|
||||
})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["j", "."]).await;
|
||||
cx.assert_shared_state(indoc! {
|
||||
});
|
||||
cx.simulate_shared_keystrokes("j .").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {
|
||||
" brown
|
||||
ˇ over
|
||||
the lazy dog"
|
||||
})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["j", "2", "."]).await;
|
||||
cx.assert_shared_state(indoc! {
|
||||
});
|
||||
cx.simulate_shared_keystrokes("j 2 .").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {
|
||||
" brown
|
||||
over
|
||||
ˇe lazy dog"
|
||||
})
|
||||
.await;
|
||||
});
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
|
@ -496,8 +481,8 @@ mod test {
|
|||
let mut cx = VimTestContext::new(cx, true).await;
|
||||
|
||||
cx.set_state("ˇhello\n", Mode::Normal);
|
||||
cx.simulate_keystrokes(["4", "i", "j", "cmd-shift-p", "escape"]);
|
||||
cx.simulate_keystrokes(["escape"]);
|
||||
cx.simulate_keystrokes("4 i j cmd-shift-p escape");
|
||||
cx.simulate_keystrokes("escape");
|
||||
cx.assert_state("ˇjhello\n", Mode::Normal);
|
||||
}
|
||||
|
||||
|
@ -506,11 +491,10 @@ mod test {
|
|||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
|
||||
cx.set_shared_state("ˇhello hello hello\n").await;
|
||||
cx.simulate_shared_keystrokes(["c", "f", "o", "x", "escape"])
|
||||
.await;
|
||||
cx.assert_shared_state("ˇx hello hello\n").await;
|
||||
cx.simulate_shared_keystrokes([":", "escape"]).await;
|
||||
cx.simulate_shared_keystrokes(["."]).await;
|
||||
cx.assert_shared_state("ˇx hello\n").await;
|
||||
cx.simulate_shared_keystrokes("c f o x escape").await;
|
||||
cx.shared_state().await.assert_eq("ˇx hello hello\n");
|
||||
cx.simulate_shared_keystrokes(": escape").await;
|
||||
cx.simulate_shared_keystrokes(".").await;
|
||||
cx.shared_state().await.assert_eq("ˇx hello\n");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -170,25 +170,25 @@ mod test {
|
|||
cx.update_editor(|editor, cx| {
|
||||
assert_eq!(editor.snapshot(cx).scroll_position(), point(0., 0.))
|
||||
});
|
||||
cx.simulate_keystrokes(["ctrl-e"]);
|
||||
cx.simulate_keystrokes("ctrl-e");
|
||||
cx.update_editor(|editor, cx| {
|
||||
assert_eq!(editor.snapshot(cx).scroll_position(), point(0., 1.))
|
||||
});
|
||||
cx.simulate_keystrokes(["2", "ctrl-e"]);
|
||||
cx.simulate_keystrokes("2 ctrl-e");
|
||||
cx.update_editor(|editor, cx| {
|
||||
assert_eq!(editor.snapshot(cx).scroll_position(), point(0., 3.))
|
||||
});
|
||||
cx.simulate_keystrokes(["ctrl-y"]);
|
||||
cx.simulate_keystrokes("ctrl-y");
|
||||
cx.update_editor(|editor, cx| {
|
||||
assert_eq!(editor.snapshot(cx).scroll_position(), point(0., 2.))
|
||||
});
|
||||
|
||||
// does not select in normal mode
|
||||
cx.simulate_keystrokes(["g", "g"]);
|
||||
cx.simulate_keystrokes("g g");
|
||||
cx.update_editor(|editor, cx| {
|
||||
assert_eq!(editor.snapshot(cx).scroll_position(), point(0., 0.))
|
||||
});
|
||||
cx.simulate_keystrokes(["ctrl-d"]);
|
||||
cx.simulate_keystrokes("ctrl-d");
|
||||
cx.update_editor(|editor, cx| {
|
||||
assert_eq!(editor.snapshot(cx).scroll_position(), point(0., 3.0));
|
||||
assert_eq!(
|
||||
|
@ -198,11 +198,11 @@ mod test {
|
|||
});
|
||||
|
||||
// does select in visual mode
|
||||
cx.simulate_keystrokes(["g", "g"]);
|
||||
cx.simulate_keystrokes("g g");
|
||||
cx.update_editor(|editor, cx| {
|
||||
assert_eq!(editor.snapshot(cx).scroll_position(), point(0., 0.))
|
||||
});
|
||||
cx.simulate_keystrokes(["v", "ctrl-d"]);
|
||||
cx.simulate_keystrokes("v ctrl-d");
|
||||
cx.update_editor(|editor, cx| {
|
||||
assert_eq!(editor.snapshot(cx).scroll_position(), point(0., 3.0));
|
||||
assert_eq!(
|
||||
|
@ -234,18 +234,18 @@ mod test {
|
|||
|
||||
// skip over the scrolloff at the top
|
||||
// test ctrl-d
|
||||
cx.simulate_shared_keystrokes(["4", "j", "ctrl-d"]).await;
|
||||
cx.assert_state_matches().await;
|
||||
cx.simulate_shared_keystrokes(["ctrl-d"]).await;
|
||||
cx.assert_state_matches().await;
|
||||
cx.simulate_shared_keystrokes(["g", "g", "ctrl-d"]).await;
|
||||
cx.assert_state_matches().await;
|
||||
cx.simulate_shared_keystrokes("4 j ctrl-d").await;
|
||||
cx.shared_state().await.assert_matches();
|
||||
cx.simulate_shared_keystrokes("ctrl-d").await;
|
||||
cx.shared_state().await.assert_matches();
|
||||
cx.simulate_shared_keystrokes("g g ctrl-d").await;
|
||||
cx.shared_state().await.assert_matches();
|
||||
|
||||
// test ctrl-u
|
||||
cx.simulate_shared_keystrokes(["ctrl-u"]).await;
|
||||
cx.assert_state_matches().await;
|
||||
cx.simulate_shared_keystrokes(["ctrl-d", "ctrl-d", "4", "j", "ctrl-u", "ctrl-u"])
|
||||
cx.simulate_shared_keystrokes("ctrl-u").await;
|
||||
cx.shared_state().await.assert_matches();
|
||||
cx.simulate_shared_keystrokes("ctrl-d ctrl-d 4 j ctrl-u ctrl-u")
|
||||
.await;
|
||||
cx.assert_state_matches().await;
|
||||
cx.shared_state().await.assert_matches();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -523,34 +523,34 @@ mod test {
|
|||
let mut cx = VimTestContext::new(cx, true).await;
|
||||
cx.set_state("ˇhi\nhigh\nhi\n", Mode::Normal);
|
||||
|
||||
cx.simulate_keystrokes(["*"]);
|
||||
cx.simulate_keystrokes("*");
|
||||
cx.run_until_parked();
|
||||
cx.assert_state("hi\nhigh\nˇhi\n", Mode::Normal);
|
||||
|
||||
cx.simulate_keystrokes(["*"]);
|
||||
cx.simulate_keystrokes("*");
|
||||
cx.run_until_parked();
|
||||
cx.assert_state("ˇhi\nhigh\nhi\n", Mode::Normal);
|
||||
|
||||
cx.simulate_keystrokes(["#"]);
|
||||
cx.simulate_keystrokes("#");
|
||||
cx.run_until_parked();
|
||||
cx.assert_state("hi\nhigh\nˇhi\n", Mode::Normal);
|
||||
|
||||
cx.simulate_keystrokes(["#"]);
|
||||
cx.simulate_keystrokes("#");
|
||||
cx.run_until_parked();
|
||||
cx.assert_state("ˇhi\nhigh\nhi\n", Mode::Normal);
|
||||
|
||||
cx.simulate_keystrokes(["2", "*"]);
|
||||
cx.simulate_keystrokes("2 *");
|
||||
cx.run_until_parked();
|
||||
cx.assert_state("ˇhi\nhigh\nhi\n", Mode::Normal);
|
||||
|
||||
cx.simulate_keystrokes(["g", "*"]);
|
||||
cx.simulate_keystrokes("g *");
|
||||
cx.run_until_parked();
|
||||
cx.assert_state("hi\nˇhigh\nhi\n", Mode::Normal);
|
||||
|
||||
cx.simulate_keystrokes(["n"]);
|
||||
cx.simulate_keystrokes("n");
|
||||
cx.assert_state("hi\nhigh\nˇhi\n", Mode::Normal);
|
||||
|
||||
cx.simulate_keystrokes(["g", "#"]);
|
||||
cx.simulate_keystrokes("g #");
|
||||
cx.run_until_parked();
|
||||
cx.assert_state("hi\nˇhigh\nhi\n", Mode::Normal);
|
||||
}
|
||||
|
@ -560,7 +560,7 @@ mod test {
|
|||
let mut cx = VimTestContext::new(cx, true).await;
|
||||
|
||||
cx.set_state("aa\nbˇb\ncc\ncc\ncc\n", Mode::Normal);
|
||||
cx.simulate_keystrokes(["/", "c", "c"]);
|
||||
cx.simulate_keystrokes("/ c c");
|
||||
|
||||
let search_bar = cx.workspace(|workspace, cx| {
|
||||
workspace
|
||||
|
@ -587,50 +587,50 @@ mod test {
|
|||
)
|
||||
});
|
||||
|
||||
cx.simulate_keystrokes(["enter"]);
|
||||
cx.simulate_keystrokes("enter");
|
||||
cx.assert_state("aa\nbb\nˇcc\ncc\ncc\n", Mode::Normal);
|
||||
|
||||
// n to go to next/N to go to previous
|
||||
cx.simulate_keystrokes(["n"]);
|
||||
cx.simulate_keystrokes("n");
|
||||
cx.assert_state("aa\nbb\ncc\nˇcc\ncc\n", Mode::Normal);
|
||||
cx.simulate_keystrokes(["shift-n"]);
|
||||
cx.simulate_keystrokes("shift-n");
|
||||
cx.assert_state("aa\nbb\nˇcc\ncc\ncc\n", Mode::Normal);
|
||||
|
||||
// ?<enter> to go to previous
|
||||
cx.simulate_keystrokes(["?", "enter"]);
|
||||
cx.simulate_keystrokes("? enter");
|
||||
cx.assert_state("aa\nbb\ncc\ncc\nˇcc\n", Mode::Normal);
|
||||
cx.simulate_keystrokes(["?", "enter"]);
|
||||
cx.simulate_keystrokes("? enter");
|
||||
cx.assert_state("aa\nbb\ncc\nˇcc\ncc\n", Mode::Normal);
|
||||
|
||||
// /<enter> to go to next
|
||||
cx.simulate_keystrokes(["/", "enter"]);
|
||||
cx.simulate_keystrokes("/ enter");
|
||||
cx.assert_state("aa\nbb\ncc\ncc\nˇcc\n", Mode::Normal);
|
||||
|
||||
// ?{search}<enter> to search backwards
|
||||
cx.simulate_keystrokes(["?", "b", "enter"]);
|
||||
cx.simulate_keystrokes("? b enter");
|
||||
cx.assert_state("aa\nbˇb\ncc\ncc\ncc\n", Mode::Normal);
|
||||
|
||||
// works with counts
|
||||
cx.simulate_keystrokes(["4", "/", "c"]);
|
||||
cx.simulate_keystrokes(["enter"]);
|
||||
cx.simulate_keystrokes("4 / c");
|
||||
cx.simulate_keystrokes("enter");
|
||||
cx.assert_state("aa\nbb\ncc\ncˇc\ncc\n", Mode::Normal);
|
||||
|
||||
// check that searching resumes from cursor, not previous match
|
||||
cx.set_state("ˇaa\nbb\ndd\ncc\nbb\n", Mode::Normal);
|
||||
cx.simulate_keystrokes(["/", "d"]);
|
||||
cx.simulate_keystrokes(["enter"]);
|
||||
cx.simulate_keystrokes("/ d");
|
||||
cx.simulate_keystrokes("enter");
|
||||
cx.assert_state("aa\nbb\nˇdd\ncc\nbb\n", Mode::Normal);
|
||||
cx.update_editor(|editor, cx| editor.move_to_beginning(&Default::default(), cx));
|
||||
cx.assert_state("ˇaa\nbb\ndd\ncc\nbb\n", Mode::Normal);
|
||||
cx.simulate_keystrokes(["/", "b"]);
|
||||
cx.simulate_keystrokes(["enter"]);
|
||||
cx.simulate_keystrokes("/ b");
|
||||
cx.simulate_keystrokes("enter");
|
||||
cx.assert_state("aa\nˇbb\ndd\ncc\nbb\n", Mode::Normal);
|
||||
|
||||
// check that searching switches to normal mode if in visual mode
|
||||
cx.set_state("ˇone two one", Mode::Normal);
|
||||
cx.simulate_keystrokes(["v", "l", "l"]);
|
||||
cx.simulate_keystrokes("v l l");
|
||||
cx.assert_editor_state("«oneˇ» two one");
|
||||
cx.simulate_keystrokes(["*"]);
|
||||
cx.simulate_keystrokes("*");
|
||||
cx.assert_state("one two ˇone", Mode::Normal);
|
||||
}
|
||||
|
||||
|
@ -638,13 +638,13 @@ mod test {
|
|||
async fn test_non_vim_search(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = VimTestContext::new(cx, false).await;
|
||||
cx.set_state("ˇone one one one", Mode::Normal);
|
||||
cx.simulate_keystrokes(["cmd-f"]);
|
||||
cx.simulate_keystrokes("cmd-f");
|
||||
cx.run_until_parked();
|
||||
|
||||
cx.assert_editor_state("«oneˇ» one one one");
|
||||
cx.simulate_keystrokes(["enter"]);
|
||||
cx.simulate_keystrokes("enter");
|
||||
cx.assert_editor_state("one «oneˇ» one one");
|
||||
cx.simulate_keystrokes(["shift-enter"]);
|
||||
cx.simulate_keystrokes("shift-enter");
|
||||
cx.assert_editor_state("«oneˇ» one one one");
|
||||
}
|
||||
|
||||
|
@ -653,9 +653,8 @@ mod test {
|
|||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
|
||||
cx.set_shared_state("ˇa.c. abcd a.c. abcd").await;
|
||||
cx.simulate_shared_keystrokes(["v", "3", "l", "*"]).await;
|
||||
cx.assert_shared_state("a.c. abcd ˇa.c. abcd").await;
|
||||
cx.assert_shared_mode(Mode::Normal).await;
|
||||
cx.simulate_shared_keystrokes("v 3 l *").await;
|
||||
cx.shared_state().await.assert_eq("a.c. abcd ˇa.c. abcd");
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
|
@ -663,9 +662,9 @@ mod test {
|
|||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
|
||||
cx.set_shared_state("ˇa.c. abcd a.c. abcd").await;
|
||||
cx.simulate_shared_keystrokes(["d", "/", "c", "d"]).await;
|
||||
cx.simulate_shared_keystrokes(["enter"]).await;
|
||||
cx.assert_shared_state("ˇcd a.c. abcd").await;
|
||||
cx.simulate_shared_keystrokes("d / c d").await;
|
||||
cx.simulate_shared_keystrokes("enter").await;
|
||||
cx.shared_state().await.assert_eq("ˇcd a.c. abcd");
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
|
@ -673,24 +672,24 @@ mod test {
|
|||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
|
||||
cx.set_shared_state("ˇa.c. abcd a.c. abcd").await;
|
||||
cx.simulate_shared_keystrokes(["v", "/", "c", "d"]).await;
|
||||
cx.simulate_shared_keystrokes(["enter"]).await;
|
||||
cx.assert_shared_state("«a.c. abcˇ»d a.c. abcd").await;
|
||||
cx.simulate_shared_keystrokes("v / c d").await;
|
||||
cx.simulate_shared_keystrokes("enter").await;
|
||||
cx.shared_state().await.assert_eq("«a.c. abcˇ»d a.c. abcd");
|
||||
|
||||
cx.set_shared_state("a a aˇ a a a").await;
|
||||
cx.simulate_shared_keystrokes(["v", "/", "a"]).await;
|
||||
cx.simulate_shared_keystrokes(["enter"]).await;
|
||||
cx.assert_shared_state("a a a« aˇ» a a").await;
|
||||
cx.simulate_shared_keystrokes(["/", "enter"]).await;
|
||||
cx.assert_shared_state("a a a« a aˇ» a").await;
|
||||
cx.simulate_shared_keystrokes(["?", "enter"]).await;
|
||||
cx.assert_shared_state("a a a« aˇ» a a").await;
|
||||
cx.simulate_shared_keystrokes(["?", "enter"]).await;
|
||||
cx.assert_shared_state("a a «ˇa »a a a").await;
|
||||
cx.simulate_shared_keystrokes(["/", "enter"]).await;
|
||||
cx.assert_shared_state("a a a« aˇ» a a").await;
|
||||
cx.simulate_shared_keystrokes(["/", "enter"]).await;
|
||||
cx.assert_shared_state("a a a« a aˇ» a").await;
|
||||
cx.simulate_shared_keystrokes("v / a").await;
|
||||
cx.simulate_shared_keystrokes("enter").await;
|
||||
cx.shared_state().await.assert_eq("a a a« aˇ» a a");
|
||||
cx.simulate_shared_keystrokes("/ enter").await;
|
||||
cx.shared_state().await.assert_eq("a a a« a aˇ» a");
|
||||
cx.simulate_shared_keystrokes("? enter").await;
|
||||
cx.shared_state().await.assert_eq("a a a« aˇ» a a");
|
||||
cx.simulate_shared_keystrokes("? enter").await;
|
||||
cx.shared_state().await.assert_eq("a a «ˇa »a a a");
|
||||
cx.simulate_shared_keystrokes("/ enter").await;
|
||||
cx.shared_state().await.assert_eq("a a a« aˇ» a a");
|
||||
cx.simulate_shared_keystrokes("/ enter").await;
|
||||
cx.shared_state().await.assert_eq("a a a« a aˇ» a");
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
|
@ -704,16 +703,14 @@ mod test {
|
|||
"
|
||||
})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["ctrl-v", "j", "/", "f"])
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["enter"]).await;
|
||||
cx.assert_shared_state(indoc! {
|
||||
cx.simulate_shared_keystrokes("ctrl-v j / f").await;
|
||||
cx.simulate_shared_keystrokes("enter").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {
|
||||
"«one twoˇ»
|
||||
«three fˇ»our
|
||||
five six
|
||||
"
|
||||
})
|
||||
.await;
|
||||
});
|
||||
}
|
||||
|
||||
// cargo test -p vim --features neovim test_replace_with_range
|
||||
|
@ -732,10 +729,9 @@ mod test {
|
|||
"
|
||||
})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes([":", "2", ",", "5", "s", "/", "a", "/", "b"])
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["enter"]).await;
|
||||
cx.assert_shared_state(indoc! {
|
||||
cx.simulate_shared_keystrokes(": 2 , 5 s / a / b").await;
|
||||
cx.simulate_shared_keystrokes("enter").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {
|
||||
"a
|
||||
b
|
||||
b
|
||||
|
@ -744,7 +740,6 @@ mod test {
|
|||
a
|
||||
a
|
||||
"
|
||||
})
|
||||
.await;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,37 +95,37 @@ mod test {
|
|||
|
||||
// supports a single cursor
|
||||
cx.set_state(indoc! {"ˇabc\n"}, Mode::Normal);
|
||||
cx.simulate_keystrokes(["s", "x"]);
|
||||
cx.simulate_keystrokes("s x");
|
||||
cx.assert_editor_state("xˇbc\n");
|
||||
|
||||
// supports a selection
|
||||
cx.set_state(indoc! {"a«bcˇ»\n"}, Mode::Visual);
|
||||
cx.assert_editor_state("a«bcˇ»\n");
|
||||
cx.simulate_keystrokes(["s", "x"]);
|
||||
cx.simulate_keystrokes("s x");
|
||||
cx.assert_editor_state("axˇ\n");
|
||||
|
||||
// supports counts
|
||||
cx.set_state(indoc! {"ˇabc\n"}, Mode::Normal);
|
||||
cx.simulate_keystrokes(["2", "s", "x"]);
|
||||
cx.simulate_keystrokes("2 s x");
|
||||
cx.assert_editor_state("xˇc\n");
|
||||
|
||||
// supports multiple cursors
|
||||
cx.set_state(indoc! {"a«bcˇ»deˇffg\n"}, Mode::Normal);
|
||||
cx.simulate_keystrokes(["2", "s", "x"]);
|
||||
cx.simulate_keystrokes("2 s x");
|
||||
cx.assert_editor_state("axˇdexˇg\n");
|
||||
|
||||
// does not read beyond end of line
|
||||
cx.set_state(indoc! {"ˇabc\n"}, Mode::Normal);
|
||||
cx.simulate_keystrokes(["5", "s", "x"]);
|
||||
cx.simulate_keystrokes("5 s x");
|
||||
cx.assert_editor_state("xˇ\n");
|
||||
|
||||
// it handles multibyte characters
|
||||
cx.set_state(indoc! {"ˇcàfé\n"}, Mode::Normal);
|
||||
cx.simulate_keystrokes(["4", "s"]);
|
||||
cx.simulate_keystrokes("4 s");
|
||||
cx.assert_editor_state("ˇ\n");
|
||||
|
||||
// should transactionally undo selection changes
|
||||
cx.simulate_keystrokes(["escape", "u"]);
|
||||
cx.simulate_keystrokes("escape u");
|
||||
cx.assert_editor_state("ˇcàfé\n");
|
||||
|
||||
// it handles visual line mode
|
||||
|
@ -136,7 +136,7 @@ mod test {
|
|||
gamma"},
|
||||
Mode::Normal,
|
||||
);
|
||||
cx.simulate_keystrokes(["shift-v", "s"]);
|
||||
cx.simulate_keystrokes("shift-v s");
|
||||
cx.assert_editor_state(indoc! {"
|
||||
alpha
|
||||
ˇ
|
||||
|
@ -148,66 +148,86 @@ mod test {
|
|||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
|
||||
cx.set_shared_state("The quick ˇbrown").await;
|
||||
cx.simulate_shared_keystrokes(["v", "w", "c"]).await;
|
||||
cx.assert_shared_state("The quick ˇ").await;
|
||||
cx.simulate_shared_keystrokes("v w c").await;
|
||||
cx.shared_state().await.assert_eq("The quick ˇ");
|
||||
|
||||
cx.set_shared_state(indoc! {"
|
||||
The ˇquick brown
|
||||
fox jumps over
|
||||
the lazy dog"})
|
||||
.await;
|
||||
cx.simulate_shared_keystrokes(["v", "w", "j", "c"]).await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
cx.simulate_shared_keystrokes("v w j c").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
The ˇver
|
||||
the lazy dog"})
|
||||
.await;
|
||||
the lazy dog"});
|
||||
|
||||
let cases = cx.each_marked_position(indoc! {"
|
||||
The ˇquick brown
|
||||
fox jumps ˇover
|
||||
the ˇlazy dog"});
|
||||
for initial_state in cases {
|
||||
cx.assert_neovim_compatible(&initial_state, ["v", "w", "j", "c"])
|
||||
.await;
|
||||
cx.assert_neovim_compatible(&initial_state, ["v", "w", "k", "c"])
|
||||
.await;
|
||||
}
|
||||
cx.simulate_at_each_offset(
|
||||
"v w j c",
|
||||
indoc! {"
|
||||
The ˇquick brown
|
||||
fox jumps ˇover
|
||||
the ˇlazy dog"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate_at_each_offset(
|
||||
"v w k c",
|
||||
indoc! {"
|
||||
The ˇquick brown
|
||||
fox jumps ˇover
|
||||
the ˇlazy dog"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_visual_line_change(cx: &mut gpui::TestAppContext) {
|
||||
let mut cx = NeovimBackedTestContext::new(cx)
|
||||
.await
|
||||
.binding(["shift-v", "c"]);
|
||||
cx.assert(indoc! {"
|
||||
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||
cx.simulate(
|
||||
"shift-v c",
|
||||
indoc! {"
|
||||
The quˇick brown
|
||||
fox jumps over
|
||||
the lazy dog"})
|
||||
.await;
|
||||
the lazy dog"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
// Test pasting code copied on change
|
||||
cx.simulate_shared_keystrokes(["escape", "j", "p"]).await;
|
||||
cx.assert_state_matches().await;
|
||||
cx.simulate_shared_keystrokes("escape j p").await;
|
||||
cx.shared_state().await.assert_matches();
|
||||
|
||||
cx.assert_all(indoc! {"
|
||||
cx.simulate_at_each_offset(
|
||||
"shift-v c",
|
||||
indoc! {"
|
||||
The quick brown
|
||||
fox juˇmps over
|
||||
the laˇzy dog"})
|
||||
.await;
|
||||
let mut cx = cx.binding(["shift-v", "j", "c"]);
|
||||
cx.assert(indoc! {"
|
||||
the laˇzy dog"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
cx.simulate(
|
||||
"shift-v j c",
|
||||
indoc! {"
|
||||
The quˇick brown
|
||||
fox jumps over
|
||||
the lazy dog"})
|
||||
.await;
|
||||
the lazy dog"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
// Test pasting code copied on delete
|
||||
cx.simulate_shared_keystrokes(["escape", "j", "p"]).await;
|
||||
cx.assert_state_matches().await;
|
||||
cx.simulate_shared_keystrokes("escape j p").await;
|
||||
cx.shared_state().await.assert_matches();
|
||||
|
||||
cx.assert_all(indoc! {"
|
||||
cx.simulate_at_each_offset(
|
||||
"shift-v j c",
|
||||
indoc! {"
|
||||
The quick brown
|
||||
fox juˇmps over
|
||||
the laˇzy dog"})
|
||||
.await;
|
||||
the laˇzy dog"},
|
||||
)
|
||||
.await
|
||||
.assert_matches();
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
|
@ -222,55 +242,46 @@ mod test {
|
|||
|
||||
// normal mode
|
||||
cx.set_shared_state(initial_state).await;
|
||||
cx.simulate_shared_keystrokes(["shift-s", "o"]).await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
cx.simulate_shared_keystrokes("shift-s o").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
The quick brown
|
||||
oˇ
|
||||
the lazy dog
|
||||
"})
|
||||
.await;
|
||||
"});
|
||||
|
||||
// visual mode
|
||||
cx.set_shared_state(initial_state).await;
|
||||
cx.simulate_shared_keystrokes(["v", "k", "shift-s", "o"])
|
||||
.await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
cx.simulate_shared_keystrokes("v k shift-s o").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
oˇ
|
||||
the lazy dog
|
||||
"})
|
||||
.await;
|
||||
"});
|
||||
|
||||
// visual block mode
|
||||
cx.set_shared_state(initial_state).await;
|
||||
cx.simulate_shared_keystrokes(["ctrl-v", "j", "shift-s", "o"])
|
||||
.await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
cx.simulate_shared_keystrokes("ctrl-v j shift-s o").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
The quick brown
|
||||
oˇ
|
||||
"})
|
||||
.await;
|
||||
"});
|
||||
|
||||
// visual mode including newline
|
||||
cx.set_shared_state(initial_state).await;
|
||||
cx.simulate_shared_keystrokes(["v", "$", "shift-s", "o"])
|
||||
.await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
cx.simulate_shared_keystrokes("v $ shift-s o").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
The quick brown
|
||||
oˇ
|
||||
the lazy dog
|
||||
"})
|
||||
.await;
|
||||
"});
|
||||
|
||||
// indentation
|
||||
cx.set_neovim_option("shiftwidth=4").await;
|
||||
cx.set_shared_state(initial_state).await;
|
||||
cx.simulate_shared_keystrokes([">", ">", "shift-s", "o"])
|
||||
.await;
|
||||
cx.assert_shared_state(indoc! {"
|
||||
cx.simulate_shared_keystrokes("> > shift-s o").await;
|
||||
cx.shared_state().await.assert_eq(indoc! {"
|
||||
The quick brown
|
||||
oˇ
|
||||
the lazy dog
|
||||
"})
|
||||
.await;
|
||||
"});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue