diff --git a/crates/vim2/src/normal/repeat.rs b/crates/vim2/src/normal/repeat.rs index a5a43b8389..a643c126ef 100644 --- a/crates/vim2/src/normal/repeat.rs +++ b/crates/vim2/src/normal/repeat.rs @@ -196,328 +196,301 @@ pub(crate) fn repeat(cx: &mut WindowContext, from_insert_mode: bool) { .detach_and_log_err(cx); } -// #[cfg(test)] -// mod test { -// use std::sync::Arc; +#[cfg(test)] +mod test { + use editor::test::editor_lsp_test_context::EditorLspTestContext; + use futures::StreamExt; + use indoc::indoc; -// use editor::test::editor_lsp_test_context::EditorLspTestContext; -// use futures::StreamExt; -// use indoc::indoc; + use gpui::InputHandler; -// use gpui::{executor::Deterministic, View}; + use crate::{ + state::Mode, + test::{NeovimBackedTestContext, VimTestContext}, + }; -// use crate::{ -// state::Mode, -// test::{NeovimBackedTestContext, VimTestContext}, -// }; + #[gpui::test] + async fn test_dot_repeat(cx: &mut gpui::TestAppContext) { + let mut cx = NeovimBackedTestContext::new(cx).await; -// #[gpui::test] -// async fn test_dot_repeat(deterministic: Arc, cx: &mut gpui::TestAppContext) { -// let mut cx = NeovimBackedTestContext::new(cx).await; + // "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; -// // "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; -// deterministic.run_until_parked(); -// cx.assert_shared_state("hello\nworld\nworlˇd").await; + // "d" + cx.simulate_shared_keystrokes(["^", "d", "f", "o"]).await; + cx.simulate_shared_keystrokes(["g", "g", "."]).await; + cx.assert_shared_state("ˇ\nworld\nrld").await; -// // "d" -// cx.simulate_shared_keystrokes(["^", "d", "f", "o"]).await; -// cx.simulate_shared_keystrokes(["g", "g", "."]).await; -// deterministic.run_until_parked(); -// cx.assert_shared_state("ˇ\nworld\nrld").await; + // "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; -// // "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; -// deterministic.run_until_parked(); -// cx.assert_shared_state("\nworld\nworld\nrld\nˇrld").await; + // "~" (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.set_shared_state("THE ˇquick brown fox").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; + } -// // "~" (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; -// deterministic.run_until_parked(); -// cx.set_shared_state("THE ˇquick brown fox").await; -// cx.simulate_shared_keystrokes(["3", "."]).await; -// deterministic.run_until_parked(); -// cx.set_shared_state("THE QUIˇck brown fox").await; -// deterministic.run_until_parked(); -// cx.simulate_shared_keystrokes(["."]).await; -// deterministic.run_until_parked(); -// cx.assert_shared_state("THE QUICK ˇbrown fox").await; -// } + #[gpui::test] + async fn test_repeat_ime(cx: &mut gpui::TestAppContext) { + let mut cx = VimTestContext::new(cx, true).await; -// #[gpui::test] -// async fn test_repeat_ime(deterministic: Arc, cx: &mut gpui::TestAppContext) { -// let mut cx = VimTestContext::new(cx, true).await; + cx.set_state("hˇllo", Mode::Normal); + cx.simulate_keystrokes(["i"]); -// cx.set_state("hˇllo", Mode::Normal); -// 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.assert_state("hˇällo", Mode::Normal); + cx.simulate_keystrokes(["."]); + cx.assert_state("hˇäällo", Mode::Normal); + } -// // 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.assert_state("hˇällo", Mode::Normal); -// cx.simulate_keystrokes(["."]); -// deterministic.run_until_parked(); -// cx.assert_state("hˇäällo", Mode::Normal); -// } + #[gpui::test] + async fn test_repeat_completion(cx: &mut gpui::TestAppContext) { + VimTestContext::init(cx); + let cx = EditorLspTestContext::new_rust( + lsp::ServerCapabilities { + completion_provider: Some(lsp::CompletionOptions { + trigger_characters: Some(vec![".".to_string(), ":".to_string()]), + resolve_provider: Some(true), + ..Default::default() + }), + ..Default::default() + }, + cx, + ) + .await; + let mut cx = VimTestContext::new_with_lsp(cx, true); -// #[gpui::test] -// async fn test_repeat_completion( -// deterministic: Arc, -// cx: &mut gpui::TestAppContext, -// ) { -// let cx = EditorLspTestContext::new_rust( -// lsp::ServerCapabilities { -// completion_provider: Some(lsp::CompletionOptions { -// trigger_characters: Some(vec![".".to_string(), ":".to_string()]), -// resolve_provider: Some(true), -// ..Default::default() -// }), -// ..Default::default() -// }, -// cx, -// ) -// .await; -// let mut cx = VimTestContext::new_with_lsp(cx, true); + cx.set_state( + indoc! {" + onˇe + two + three + "}, + Mode::Normal, + ); -// cx.set_state( -// indoc! {" -// onˇe -// two -// three -// "}, -// Mode::Normal, -// ); + let mut request = + cx.handle_request::(move |_, params, _| async move { + let position = params.text_document_position.position; + Ok(Some(lsp::CompletionResponse::Array(vec![ + lsp::CompletionItem { + label: "first".to_string(), + text_edit: Some(lsp::CompletionTextEdit::Edit(lsp::TextEdit { + range: lsp::Range::new(position.clone(), position.clone()), + new_text: "first".to_string(), + })), + ..Default::default() + }, + lsp::CompletionItem { + label: "second".to_string(), + text_edit: Some(lsp::CompletionTextEdit::Edit(lsp::TextEdit { + range: lsp::Range::new(position.clone(), position.clone()), + new_text: "second".to_string(), + })), + ..Default::default() + }, + ]))) + }); + cx.simulate_keystrokes(["a", "."]); + request.next().await; + cx.condition(|editor, _| editor.context_menu_visible()) + .await; + cx.simulate_keystrokes(["down", "enter", "!", "escape"]); -// let mut request = -// cx.handle_request::(move |_, params, _| async move { -// let position = params.text_document_position.position; -// Ok(Some(lsp::CompletionResponse::Array(vec![ -// lsp::CompletionItem { -// label: "first".to_string(), -// text_edit: Some(lsp::CompletionTextEdit::Edit(lsp::TextEdit { -// range: lsp::Range::new(position.clone(), position.clone()), -// new_text: "first".to_string(), -// })), -// ..Default::default() -// }, -// lsp::CompletionItem { -// label: "second".to_string(), -// text_edit: Some(lsp::CompletionTextEdit::Edit(lsp::TextEdit { -// range: lsp::Range::new(position.clone(), position.clone()), -// new_text: "second".to_string(), -// })), -// ..Default::default() -// }, -// ]))) -// }); -// cx.simulate_keystrokes(["a", "."]); -// request.next().await; -// cx.condition(|editor, _| editor.context_menu_visible()) -// .await; -// cx.simulate_keystrokes(["down", "enter", "!", "escape"]); + cx.assert_state( + indoc! {" + one.secondˇ! + two + three + "}, + Mode::Normal, + ); + cx.simulate_keystrokes(["j", "."]); + cx.assert_state( + indoc! {" + one.second! + two.secondˇ! + three + "}, + Mode::Normal, + ); + } -// cx.assert_state( -// indoc! {" -// one.secondˇ! -// two -// three -// "}, -// Mode::Normal, -// ); -// cx.simulate_keystrokes(["j", "."]); -// deterministic.run_until_parked(); -// cx.assert_state( -// indoc! {" -// one.second! -// two.secondˇ! -// three -// "}, -// Mode::Normal, -// ); -// } + #[gpui::test] + async fn test_repeat_visual(cx: &mut gpui::TestAppContext) { + let mut cx = NeovimBackedTestContext::new(cx).await; -// #[gpui::test] -// async fn test_repeat_visual(deterministic: Arc, cx: &mut gpui::TestAppContext) { -// let mut cx = NeovimBackedTestContext::new(cx).await; + // single-line (3 columns) + cx.set_shared_state(indoc! { + "ˇthe quick brown + fox jumps over + the lazy dog" + }) + .await; + cx.simulate_shared_keystrokes(["v", "i", "w", "s", "o", "escape"]) + .await; + cx.assert_shared_state(indoc! { + "ˇo quick brown + fox jumps over + the lazy dog" + }) + .await; + cx.simulate_shared_keystrokes(["j", "w", "."]).await; + cx.assert_shared_state(indoc! { + "o quick brown + fox ˇops over + the lazy dog" + }) + .await; + cx.simulate_shared_keystrokes(["f", "r", "."]).await; + cx.assert_shared_state(indoc! { + "o quick brown + fox ops oveˇothe lazy dog" + }) + .await; -// // single-line (3 columns) -// cx.set_shared_state(indoc! { -// "ˇthe quick brown -// fox jumps over -// the lazy dog" -// }) -// .await; -// cx.simulate_shared_keystrokes(["v", "i", "w", "s", "o", "escape"]) -// .await; -// cx.assert_shared_state(indoc! { -// "ˇo quick brown -// fox jumps over -// the lazy dog" -// }) -// .await; -// cx.simulate_shared_keystrokes(["j", "w", "."]).await; -// deterministic.run_until_parked(); -// cx.assert_shared_state(indoc! { -// "o quick brown -// fox ˇops over -// the lazy dog" -// }) -// .await; -// cx.simulate_shared_keystrokes(["f", "r", "."]).await; -// deterministic.run_until_parked(); -// cx.assert_shared_state(indoc! { -// "o quick brown -// fox ops oveˇothe lazy dog" -// }) -// .await; + // visual + cx.set_shared_state(indoc! { + "the ˇquick brown + fox jumps over + fox jumps over + fox jumps over + the lazy dog" + }) + .await; + cx.simulate_shared_keystrokes(["v", "j", "x"]).await; + cx.assert_shared_state(indoc! { + "the ˇumps over + fox jumps over + fox jumps over + the lazy dog" + }) + .await; + cx.simulate_shared_keystrokes(["."]).await; + cx.assert_shared_state(indoc! { + "the ˇumps over + fox jumps over + the lazy dog" + }) + .await; + cx.simulate_shared_keystrokes(["w", "."]).await; + cx.assert_shared_state(indoc! { + "the umps ˇumps over + the lazy dog" + }) + .await; + cx.simulate_shared_keystrokes(["j", "."]).await; + cx.assert_shared_state(indoc! { + "the umps umps over + the ˇog" + }) + .await; -// // visual -// cx.set_shared_state(indoc! { -// "the ˇquick brown -// fox jumps over -// fox jumps over -// fox jumps over -// the lazy dog" -// }) -// .await; -// cx.simulate_shared_keystrokes(["v", "j", "x"]).await; -// cx.assert_shared_state(indoc! { -// "the ˇumps over -// fox jumps over -// fox jumps over -// the lazy dog" -// }) -// .await; -// cx.simulate_shared_keystrokes(["."]).await; -// deterministic.run_until_parked(); -// cx.assert_shared_state(indoc! { -// "the ˇumps over -// fox jumps over -// the lazy dog" -// }) -// .await; -// cx.simulate_shared_keystrokes(["w", "."]).await; -// deterministic.run_until_parked(); -// cx.assert_shared_state(indoc! { -// "the umps ˇumps over -// the lazy dog" -// }) -// .await; -// cx.simulate_shared_keystrokes(["j", "."]).await; -// deterministic.run_until_parked(); -// cx.assert_shared_state(indoc! { -// "the umps umps over -// the ˇog" -// }) -// .await; + // block mode (3 rows) + cx.set_shared_state(indoc! { + "ˇthe quick brown + fox jumps over + the lazy dog" + }) + .await; + cx.simulate_shared_keystrokes(["ctrl-v", "j", "j", "shift-i", "o", "escape"]) + .await; + cx.assert_shared_state(indoc! { + "ˇothe quick brown + ofox jumps over + othe lazy dog" + }) + .await; + cx.simulate_shared_keystrokes(["j", "4", "l", "."]).await; + cx.assert_shared_state(indoc! { + "othe quick brown + ofoxˇo jumps over + otheo lazy dog" + }) + .await; -// // block mode (3 rows) -// cx.set_shared_state(indoc! { -// "ˇthe quick brown -// fox jumps over -// the lazy dog" -// }) -// .await; -// cx.simulate_shared_keystrokes(["ctrl-v", "j", "j", "shift-i", "o", "escape"]) -// .await; -// cx.assert_shared_state(indoc! { -// "ˇothe quick brown -// ofox jumps over -// othe lazy dog" -// }) -// .await; -// cx.simulate_shared_keystrokes(["j", "4", "l", "."]).await; -// deterministic.run_until_parked(); -// cx.assert_shared_state(indoc! { -// "othe quick brown -// ofoxˇo jumps over -// otheo lazy dog" -// }) -// .await; + // line mode + cx.set_shared_state(indoc! { + "ˇthe quick brown + fox jumps over + the lazy dog" + }) + .await; + cx.simulate_shared_keystrokes(["shift-v", "shift-r", "o", "escape"]) + .await; + cx.assert_shared_state(indoc! { + "ˇo + fox jumps over + the lazy dog" + }) + .await; + cx.simulate_shared_keystrokes(["j", "."]).await; + cx.assert_shared_state(indoc! { + "o + ˇo + the lazy dog" + }) + .await; + } -// // line mode -// cx.set_shared_state(indoc! { -// "ˇthe quick brown -// fox jumps over -// the lazy dog" -// }) -// .await; -// cx.simulate_shared_keystrokes(["shift-v", "shift-r", "o", "escape"]) -// .await; -// cx.assert_shared_state(indoc! { -// "ˇo -// fox jumps over -// the lazy dog" -// }) -// .await; -// cx.simulate_shared_keystrokes(["j", "."]).await; -// deterministic.run_until_parked(); -// cx.assert_shared_state(indoc! { -// "o -// ˇo -// the lazy dog" -// }) -// .await; -// } + #[gpui::test] + async fn test_repeat_motion_counts(cx: &mut gpui::TestAppContext) { + let mut cx = NeovimBackedTestContext::new(cx).await; -// #[gpui::test] -// async fn test_repeat_motion_counts( -// deterministic: Arc, -// cx: &mut gpui::TestAppContext, -// ) { -// let mut cx = NeovimBackedTestContext::new(cx).await; + cx.set_shared_state(indoc! { + "ˇthe quick brown + fox jumps over + the lazy dog" + }) + .await; + cx.simulate_shared_keystrokes(["3", "d", "3", "l"]).await; + cx.assert_shared_state(indoc! { + "ˇ brown + fox jumps over + the lazy dog" + }) + .await; + cx.simulate_shared_keystrokes(["j", "."]).await; + cx.assert_shared_state(indoc! { + " brown + ˇ over + the lazy dog" + }) + .await; + cx.simulate_shared_keystrokes(["j", "2", "."]).await; + cx.assert_shared_state(indoc! { + " brown + over + ˇe lazy dog" + }) + .await; + } -// cx.set_shared_state(indoc! { -// "ˇthe quick brown -// fox jumps over -// the lazy dog" -// }) -// .await; -// cx.simulate_shared_keystrokes(["3", "d", "3", "l"]).await; -// cx.assert_shared_state(indoc! { -// "ˇ brown -// fox jumps over -// the lazy dog" -// }) -// .await; -// cx.simulate_shared_keystrokes(["j", "."]).await; -// deterministic.run_until_parked(); -// cx.assert_shared_state(indoc! { -// " brown -// ˇ over -// the lazy dog" -// }) -// .await; -// cx.simulate_shared_keystrokes(["j", "2", "."]).await; -// deterministic.run_until_parked(); -// cx.assert_shared_state(indoc! { -// " brown -// over -// ˇe lazy dog" -// }) -// .await; -// } + #[gpui::test] + async fn test_record_interrupted(cx: &mut gpui::TestAppContext) { + let mut cx = VimTestContext::new(cx, true).await; -// #[gpui::test] -// async fn test_record_interrupted( -// deterministic: Arc, -// cx: &mut gpui::TestAppContext, -// ) { -// 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", "escape"]); -// deterministic.run_until_parked(); -// cx.assert_state("ˇjhello\n", Mode::Normal); -// } -// } + cx.set_state("ˇhello\n", Mode::Normal); + cx.simulate_keystrokes(["4", "i", "j", "cmd-shift-p", "escape"]); + cx.simulate_keystrokes(["escape"]); + cx.assert_state("ˇjhello\n", Mode::Normal); + } +} diff --git a/crates/vim2/src/normal/search.rs b/crates/vim2/src/normal/search.rs index ef26d029a5..3873c5b78b 100644 --- a/crates/vim2/src/normal/search.rs +++ b/crates/vim2/src/normal/search.rs @@ -347,58 +347,50 @@ fn parse_replace_all(query: &str) -> Replacement { // #[cfg(test)] // mod test { -// use std::sync::Arc; - // use editor::DisplayPoint; // use search::BufferSearchBar; // use crate::{state::Mode, test::VimTestContext}; // #[gpui::test] -// async fn test_move_to_next( -// cx: &mut gpui::TestAppContext, -// deterministic: Arc, -// ) { +// async fn test_move_to_next(cx: &mut gpui::TestAppContext) { // let mut cx = VimTestContext::new(cx, true).await; // cx.set_state("ˇhi\nhigh\nhi\n", Mode::Normal); // cx.simulate_keystrokes(["*"]); -// deterministic.run_until_parked(); +// cx.run_until_parked(); // cx.assert_state("hi\nhigh\nˇhi\n", Mode::Normal); // cx.simulate_keystrokes(["*"]); -// deterministic.run_until_parked(); +// cx.run_until_parked(); // cx.assert_state("ˇhi\nhigh\nhi\n", Mode::Normal); // cx.simulate_keystrokes(["#"]); -// deterministic.run_until_parked(); +// cx.run_until_parked(); // cx.assert_state("hi\nhigh\nˇhi\n", Mode::Normal); // cx.simulate_keystrokes(["#"]); -// deterministic.run_until_parked(); +// cx.run_until_parked(); // cx.assert_state("ˇhi\nhigh\nhi\n", Mode::Normal); // cx.simulate_keystrokes(["2", "*"]); -// deterministic.run_until_parked(); +// cx.run_until_parked(); // cx.assert_state("ˇhi\nhigh\nhi\n", Mode::Normal); // cx.simulate_keystrokes(["g", "*"]); -// deterministic.run_until_parked(); +// cx.run_until_parked(); // cx.assert_state("hi\nˇhigh\nhi\n", Mode::Normal); // cx.simulate_keystrokes(["n"]); // cx.assert_state("hi\nhigh\nˇhi\n", Mode::Normal); // cx.simulate_keystrokes(["g", "#"]); -// deterministic.run_until_parked(); +// cx.run_until_parked(); // cx.assert_state("hi\nˇhigh\nhi\n", Mode::Normal); // } // #[gpui::test] -// async fn test_search( -// cx: &mut gpui::TestAppContext, -// deterministic: Arc, -// ) { +// async fn test_search(cx: &mut gpui::TestAppContext) { // let mut cx = VimTestContext::new(cx, true).await; // cx.set_state("aa\nbˇb\ncc\ncc\ncc\n", Mode::Normal); @@ -414,11 +406,11 @@ fn parse_replace_all(query: &str) -> Replacement { // .expect("Buffer search bar should be deployed") // }); -// search_bar.read_with(cx.cx, |bar, cx| { +// cx.update_view(search_bar, |bar, cx| { // assert_eq!(bar.query(cx), "cc"); // }); -// deterministic.run_until_parked(); +// cx.run_until_parked(); // cx.update_editor(|editor, cx| { // let highlights = editor.all_text_background_highlights(cx); @@ -440,51 +432,41 @@ fn parse_replace_all(query: &str) -> Replacement { // // ? to go to previous // cx.simulate_keystrokes(["?", "enter"]); -// deterministic.run_until_parked(); // cx.assert_state("aa\nbb\ncc\ncc\nˇcc\n", Mode::Normal); // cx.simulate_keystrokes(["?", "enter"]); -// deterministic.run_until_parked(); // cx.assert_state("aa\nbb\ncc\nˇcc\ncc\n", Mode::Normal); // // / to go to next // cx.simulate_keystrokes(["/", "enter"]); -// deterministic.run_until_parked(); // cx.assert_state("aa\nbb\ncc\ncc\nˇcc\n", Mode::Normal); // // ?{search} to search backwards // cx.simulate_keystrokes(["?", "b", "enter"]); -// deterministic.run_until_parked(); // cx.assert_state("aa\nbˇb\ncc\ncc\ncc\n", Mode::Normal); // // works with counts // cx.simulate_keystrokes(["4", "/", "c"]); -// deterministic.run_until_parked(); // 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"]); -// deterministic.run_until_parked(); // 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"]); -// deterministic.run_until_parked(); // cx.simulate_keystrokes(["enter"]); // cx.assert_state("aa\nˇbb\ndd\ncc\nbb\n", Mode::Normal); // } // #[gpui::test] -// async fn test_non_vim_search( -// cx: &mut gpui::TestAppContext, -// deterministic: Arc, -// ) { +// 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"]); -// deterministic.run_until_parked(); +// cx.run_until_parked(); // cx.assert_editor_state("«oneˇ» one one one"); // cx.simulate_keystrokes(["enter"]); diff --git a/crates/vim2/src/test/vim_test_context.rs b/crates/vim2/src/test/vim_test_context.rs index 7b9d71ffca..3956964480 100644 --- a/crates/vim2/src/test/vim_test_context.rs +++ b/crates/vim2/src/test/vim_test_context.rs @@ -18,7 +18,11 @@ pub struct VimTestContext<'a> { } impl<'a> VimTestContext<'a> { - pub async fn new(cx: &'a mut gpui::TestAppContext, enabled: bool) -> VimTestContext<'a> { + pub fn init(cx: &mut gpui::TestAppContext) { + if cx.has_global::() { + dbg!("OOPS"); + return; + } cx.update(|cx| { search::init(cx); let settings = SettingsStore::test(cx); @@ -26,18 +30,16 @@ impl<'a> VimTestContext<'a> { command_palette::init(cx); crate::init(cx); }); + } + + pub async fn new(cx: &'a mut gpui::TestAppContext, enabled: bool) -> VimTestContext<'a> { + Self::init(cx); let lsp = EditorLspTestContext::new_rust(Default::default(), cx).await; Self::new_with_lsp(lsp, enabled) } pub async fn new_typescript(cx: &'a mut gpui::TestAppContext) -> VimTestContext<'a> { - cx.update(|cx| { - search::init(cx); - let settings = SettingsStore::test(cx); - cx.set_global(settings); - command_palette::init(cx); - crate::init(cx); - }); + Self::init(cx); Self::new_with_lsp( EditorLspTestContext::new_typescript(Default::default(), cx).await, true,