vim2 (#3619)
Fix vim command tests by restoring the spawn in command palette's confirm Release Notes: - N/A
This commit is contained in:
commit
c94c6614ed
2 changed files with 129 additions and 131 deletions
|
@ -291,7 +291,9 @@ impl PickerDelegate for CommandPaletteDelegate {
|
||||||
});
|
});
|
||||||
let action = command.action;
|
let action = command.action;
|
||||||
cx.focus(&self.previous_focus_handle);
|
cx.focus(&self.previous_focus_handle);
|
||||||
cx.dispatch_action(action);
|
cx.window_context()
|
||||||
|
.spawn(move |mut cx| async move { cx.update(|_, cx| cx.dispatch_action(action)) })
|
||||||
|
.detach_and_log_err(cx);
|
||||||
self.dismissed(cx);
|
self.dismissed(cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -288,151 +288,147 @@ fn generate_positions(string: &str, query: &str) -> Vec<usize> {
|
||||||
positions
|
positions
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[cfg(test)]
|
#[cfg(test)]
|
||||||
// mod test {
|
mod test {
|
||||||
// use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
// use crate::test::{NeovimBackedTestContext, VimTestContext};
|
use crate::test::{NeovimBackedTestContext, VimTestContext};
|
||||||
// use gpui::TestAppContext;
|
use gpui::TestAppContext;
|
||||||
// use indoc::indoc;
|
use indoc::indoc;
|
||||||
|
|
||||||
// #[gpui::test]
|
#[gpui::test]
|
||||||
// async fn test_command_basics(cx: &mut TestAppContext) {
|
async fn test_command_basics(cx: &mut TestAppContext) {
|
||||||
// if let Foreground::Deterministic { cx_id: _, executor } = cx.foreground().as_ref() {
|
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||||
// executor.run_until_parked();
|
|
||||||
// }
|
|
||||||
// let mut cx = NeovimBackedTestContext::new(cx).await;
|
|
||||||
|
|
||||||
// cx.set_shared_state(indoc! {"
|
cx.set_shared_state(indoc! {"
|
||||||
// ˇa
|
ˇa
|
||||||
// b
|
b
|
||||||
// c"})
|
c"})
|
||||||
// .await;
|
.await;
|
||||||
|
|
||||||
// cx.simulate_shared_keystrokes([":", "j", "enter"]).await;
|
cx.simulate_shared_keystrokes([":", "j", "enter"]).await;
|
||||||
|
|
||||||
// // hack: our cursor positionining after a join command is wrong
|
// hack: our cursor positionining after a join command is wrong
|
||||||
// cx.simulate_shared_keystrokes(["^"]).await;
|
cx.simulate_shared_keystrokes(["^"]).await;
|
||||||
// cx.assert_shared_state(indoc! {
|
cx.assert_shared_state(indoc! {
|
||||||
// "ˇa b
|
"ˇa b
|
||||||
// c"
|
c"
|
||||||
// })
|
})
|
||||||
// .await;
|
.await;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// #[gpui::test]
|
#[gpui::test]
|
||||||
// async fn test_command_goto(cx: &mut TestAppContext) {
|
async fn test_command_goto(cx: &mut TestAppContext) {
|
||||||
// let mut cx = NeovimBackedTestContext::new(cx).await;
|
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||||
|
|
||||||
// cx.set_shared_state(indoc! {"
|
cx.set_shared_state(indoc! {"
|
||||||
// ˇa
|
ˇa
|
||||||
// b
|
b
|
||||||
// c"})
|
c"})
|
||||||
// .await;
|
.await;
|
||||||
// cx.simulate_shared_keystrokes([":", "3", "enter"]).await;
|
cx.simulate_shared_keystrokes([":", "3", "enter"]).await;
|
||||||
// cx.assert_shared_state(indoc! {"
|
cx.assert_shared_state(indoc! {"
|
||||||
// a
|
a
|
||||||
// b
|
b
|
||||||
// ˇc"})
|
ˇc"})
|
||||||
// .await;
|
.await;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// #[gpui::test]
|
#[gpui::test]
|
||||||
// async fn test_command_replace(cx: &mut TestAppContext) {
|
async fn test_command_replace(cx: &mut TestAppContext) {
|
||||||
// let mut cx = NeovimBackedTestContext::new(cx).await;
|
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||||
|
|
||||||
// cx.set_shared_state(indoc! {"
|
cx.set_shared_state(indoc! {"
|
||||||
// ˇa
|
ˇa
|
||||||
// b
|
b
|
||||||
// c"})
|
c"})
|
||||||
// .await;
|
.await;
|
||||||
// cx.simulate_shared_keystrokes([":", "%", "s", "/", "b", "/", "d", "enter"])
|
cx.simulate_shared_keystrokes([":", "%", "s", "/", "b", "/", "d", "enter"])
|
||||||
// .await;
|
.await;
|
||||||
// cx.assert_shared_state(indoc! {"
|
cx.assert_shared_state(indoc! {"
|
||||||
// a
|
a
|
||||||
// ˇd
|
ˇd
|
||||||
// c"})
|
c"})
|
||||||
// .await;
|
.await;
|
||||||
// cx.simulate_shared_keystrokes([
|
cx.simulate_shared_keystrokes([
|
||||||
// ":", "%", "s", ":", ".", ":", "\\", "0", "\\", "0", "enter",
|
":", "%", "s", ":", ".", ":", "\\", "0", "\\", "0", "enter",
|
||||||
// ])
|
])
|
||||||
// .await;
|
.await;
|
||||||
// cx.assert_shared_state(indoc! {"
|
cx.assert_shared_state(indoc! {"
|
||||||
// aa
|
aa
|
||||||
// dd
|
dd
|
||||||
// ˇcc"})
|
ˇcc"})
|
||||||
// .await;
|
.await;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// #[gpui::test]
|
#[gpui::test]
|
||||||
// async fn test_command_search(cx: &mut TestAppContext) {
|
async fn test_command_search(cx: &mut TestAppContext) {
|
||||||
// let mut cx = NeovimBackedTestContext::new(cx).await;
|
let mut cx = NeovimBackedTestContext::new(cx).await;
|
||||||
|
|
||||||
// cx.set_shared_state(indoc! {"
|
cx.set_shared_state(indoc! {"
|
||||||
// ˇa
|
ˇa
|
||||||
// b
|
b
|
||||||
// a
|
a
|
||||||
// c"})
|
c"})
|
||||||
// .await;
|
.await;
|
||||||
// cx.simulate_shared_keystrokes([":", "/", "b", "enter"])
|
cx.simulate_shared_keystrokes([":", "/", "b", "enter"])
|
||||||
// .await;
|
.await;
|
||||||
// cx.assert_shared_state(indoc! {"
|
cx.assert_shared_state(indoc! {"
|
||||||
// a
|
a
|
||||||
// ˇb
|
ˇb
|
||||||
// a
|
a
|
||||||
// c"})
|
c"})
|
||||||
// .await;
|
.await;
|
||||||
// cx.simulate_shared_keystrokes([":", "?", "a", "enter"])
|
cx.simulate_shared_keystrokes([":", "?", "a", "enter"])
|
||||||
// .await;
|
.await;
|
||||||
// cx.assert_shared_state(indoc! {"
|
cx.assert_shared_state(indoc! {"
|
||||||
// ˇa
|
ˇa
|
||||||
// b
|
b
|
||||||
// a
|
a
|
||||||
// c"})
|
c"})
|
||||||
// .await;
|
.await;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// #[gpui::test]
|
#[gpui::test]
|
||||||
// async fn test_command_write(cx: &mut TestAppContext) {
|
async fn test_command_write(cx: &mut TestAppContext) {
|
||||||
// let mut cx = VimTestContext::new(cx, true).await;
|
let mut cx = VimTestContext::new(cx, true).await;
|
||||||
// let path = Path::new("/root/dir/file.rs");
|
let path = Path::new("/root/dir/file.rs");
|
||||||
// let fs = cx.workspace(|workspace, cx| workspace.project().read(cx).fs().clone());
|
let fs = cx.workspace(|workspace, cx| workspace.project().read(cx).fs().clone());
|
||||||
|
|
||||||
// cx.simulate_keystrokes(["i", "@", "escape"]);
|
cx.simulate_keystrokes(["i", "@", "escape"]);
|
||||||
// cx.simulate_keystrokes([":", "w", "enter"]);
|
cx.simulate_keystrokes([":", "w", "enter"]);
|
||||||
|
|
||||||
// assert_eq!(fs.load(&path).await.unwrap(), "@\n");
|
assert_eq!(fs.load(&path).await.unwrap(), "@\n");
|
||||||
|
|
||||||
// fs.as_fake()
|
fs.as_fake()
|
||||||
// .write_file_internal(path, "oops\n".to_string())
|
.write_file_internal(path, "oops\n".to_string())
|
||||||
// .unwrap();
|
.unwrap();
|
||||||
|
|
||||||
// // conflict!
|
// conflict!
|
||||||
// cx.simulate_keystrokes(["i", "@", "escape"]);
|
cx.simulate_keystrokes(["i", "@", "escape"]);
|
||||||
// cx.simulate_keystrokes([":", "w", "enter"]);
|
cx.simulate_keystrokes([":", "w", "enter"]);
|
||||||
// let window = cx.window;
|
assert!(cx.has_pending_prompt());
|
||||||
// assert!(window.has_pending_prompt(cx.cx));
|
// "Cancel"
|
||||||
// // "Cancel"
|
cx.simulate_prompt_answer(0);
|
||||||
// window.simulate_prompt_answer(0, cx.cx);
|
assert_eq!(fs.load(&path).await.unwrap(), "oops\n");
|
||||||
// assert_eq!(fs.load(&path).await.unwrap(), "oops\n");
|
assert!(!cx.has_pending_prompt());
|
||||||
// assert!(!window.has_pending_prompt(cx.cx));
|
// force overwrite
|
||||||
// // force overwrite
|
cx.simulate_keystrokes([":", "w", "!", "enter"]);
|
||||||
// cx.simulate_keystrokes([":", "w", "!", "enter"]);
|
assert!(!cx.has_pending_prompt());
|
||||||
// assert!(!window.has_pending_prompt(cx.cx));
|
assert_eq!(fs.load(&path).await.unwrap(), "@@\n");
|
||||||
// assert_eq!(fs.load(&path).await.unwrap(), "@@\n");
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
// #[gpui::test]
|
#[gpui::test]
|
||||||
// async fn test_command_quit(cx: &mut TestAppContext) {
|
async fn test_command_quit(cx: &mut TestAppContext) {
|
||||||
// let mut cx = VimTestContext::new(cx, true).await;
|
let mut cx = VimTestContext::new(cx, true).await;
|
||||||
|
|
||||||
// cx.simulate_keystrokes([":", "n", "e", "w", "enter"]);
|
cx.simulate_keystrokes([":", "n", "e", "w", "enter"]);
|
||||||
// cx.workspace(|workspace, cx| assert_eq!(workspace.items(cx).count(), 2));
|
cx.workspace(|workspace, cx| assert_eq!(workspace.items(cx).count(), 2));
|
||||||
// cx.simulate_keystrokes([":", "q", "enter"]);
|
cx.simulate_keystrokes([":", "q", "enter"]);
|
||||||
// cx.workspace(|workspace, cx| assert_eq!(workspace.items(cx).count(), 1));
|
cx.workspace(|workspace, cx| assert_eq!(workspace.items(cx).count(), 1));
|
||||||
// cx.simulate_keystrokes([":", "n", "e", "w", "enter"]);
|
cx.simulate_keystrokes([":", "n", "e", "w", "enter"]);
|
||||||
// cx.workspace(|workspace, cx| assert_eq!(workspace.items(cx).count(), 2));
|
cx.workspace(|workspace, cx| assert_eq!(workspace.items(cx).count(), 2));
|
||||||
// cx.simulate_keystrokes([":", "q", "a", "enter"]);
|
cx.simulate_keystrokes([":", "q", "a", "enter"]);
|
||||||
// cx.workspace(|workspace, cx| assert_eq!(workspace.items(cx).count(), 0));
|
cx.workspace(|workspace, cx| assert_eq!(workspace.items(cx).count(), 0));
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue