vim: Sentence motion (#17425)

Closes #12161

Release Notes:

- vim: Added `(` and `)` for sentence motion
This commit is contained in:
Conrad Irwin 2024-09-05 11:18:52 -06:00 committed by GitHub
parent 01e40928d8
commit 1e09884a22
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 276 additions and 2 deletions

View file

@ -1426,3 +1426,93 @@ async fn test_record_replay_recursion(cx: &mut gpui::TestAppContext) {
cx.simulate_shared_keystrokes(".").await;
cx.shared_state().await.assert_eq("ˇhello world"); // takes a _long_ time
}
#[gpui::test]
async fn test_sentence_backwards(cx: &mut gpui::TestAppContext) {
let mut cx = NeovimBackedTestContext::new(cx).await;
cx.set_shared_state("one\n\ntwo\nthree\nˇ\nfour").await;
cx.simulate_shared_keystrokes("(").await;
cx.shared_state()
.await
.assert_eq("one\n\nˇtwo\nthree\n\nfour");
cx.set_shared_state("hello.\n\n\nworˇld.").await;
cx.simulate_shared_keystrokes("(").await;
cx.shared_state().await.assert_eq("hello.\n\n\nˇworld.");
cx.simulate_shared_keystrokes("(").await;
cx.shared_state().await.assert_eq("hello.\n\nˇ\nworld.");
cx.simulate_shared_keystrokes("(").await;
cx.shared_state().await.assert_eq("ˇhello.\n\n\nworld.");
cx.set_shared_state("hello. worlˇd.").await;
cx.simulate_shared_keystrokes("(").await;
cx.shared_state().await.assert_eq("hello. ˇworld.");
cx.simulate_shared_keystrokes("(").await;
cx.shared_state().await.assert_eq("ˇhello. world.");
cx.set_shared_state(". helˇlo.").await;
cx.simulate_shared_keystrokes("(").await;
cx.shared_state().await.assert_eq(". ˇhello.");
cx.simulate_shared_keystrokes("(").await;
cx.shared_state().await.assert_eq(". ˇhello.");
cx.set_shared_state(indoc! {
"{
hello_world();
ˇ}"
})
.await;
cx.simulate_shared_keystrokes("(").await;
cx.shared_state().await.assert_eq(indoc! {
"ˇ{
hello_world();
}"
});
cx.set_shared_state(indoc! {
"Hello! World..?
\tHello! World... ˇ"
})
.await;
cx.simulate_shared_keystrokes("(").await;
cx.shared_state().await.assert_eq(indoc! {
"Hello! World..?
\tHello! ˇWorld... "
});
cx.simulate_shared_keystrokes("(").await;
cx.shared_state().await.assert_eq(indoc! {
"Hello! World..?
\tˇHello! World... "
});
cx.simulate_shared_keystrokes("(").await;
cx.shared_state().await.assert_eq(indoc! {
"Hello! World..?
ˇ
\tHello! World... "
});
cx.simulate_shared_keystrokes("(").await;
cx.shared_state().await.assert_eq(indoc! {
"Hello! ˇWorld..?
\tHello! World... "
});
}
#[gpui::test]
async fn test_sentence_forwards(cx: &mut gpui::TestAppContext) {
let mut cx = NeovimBackedTestContext::new(cx).await;
cx.set_shared_state("helˇlo.\n\n\nworld.").await;
cx.simulate_shared_keystrokes(")").await;
cx.shared_state().await.assert_eq("hello.\nˇ\n\nworld.");
cx.simulate_shared_keystrokes(")").await;
cx.shared_state().await.assert_eq("hello.\n\n\nˇworld.");
cx.simulate_shared_keystrokes(")").await;
cx.shared_state().await.assert_eq("hello.\n\n\nworldˇ.");
cx.set_shared_state("helˇlo.\n\n\nworld.").await;
}