From 7ae305ac0dd8ae3b113f7debacacda09b9d8ed36 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Tue, 23 Jul 2024 15:16:45 -0600 Subject: [PATCH] Make vim::test_remap less flaky on linux (#15040) Release Notes: - N/A --- crates/picker/src/picker.rs | 13 +++++++++++-- crates/vim/src/test.rs | 2 -- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/crates/picker/src/picker.rs b/crates/picker/src/picker.rs index 4c10220f37..ba223e7f53 100644 --- a/crates/picker/src/picker.rs +++ b/crates/picker/src/picker.rs @@ -22,6 +22,15 @@ enum ElementContainer { actions!(picker, [ConfirmCompletion]); +// How long to give the command palette to return if a user +// types j quickly. +// Longer in debug builds to reduce flaky test on linux. +#[cfg(debug_assertions)] +static FINALIZE_TIMEOUT: Duration = Duration::from_millis(32); + +#[cfg(not(debug_assertions))] +static FINALIZE_TIMEOUT: Duration = Duration::from_millis(16); + /// ConfirmInput is an alternative editor action which - instead of selecting active picker entry - treats pickers editor input literally, /// performing some kind of action on it. #[derive(PartialEq, Clone, Deserialize, Default)] @@ -324,7 +333,7 @@ impl Picker { if self.pending_update_matches.is_some() && !self .delegate - .finalize_update_matches(self.query(cx), Duration::from_millis(16), cx) + .finalize_update_matches(self.query(cx), FINALIZE_TIMEOUT, cx) { self.confirm_on_update = Some(false) } else { @@ -337,7 +346,7 @@ impl Picker { if self.pending_update_matches.is_some() && !self .delegate - .finalize_update_matches(self.query(cx), Duration::from_millis(16), cx) + .finalize_update_matches(self.query(cx), FINALIZE_TIMEOUT, cx) { self.confirm_on_update = Some(true) } else { diff --git a/crates/vim/src/test.rs b/crates/vim/src/test.rs index 90704df901..6729a20e41 100644 --- a/crates/vim/src/test.rs +++ b/crates/vim/src/test.rs @@ -956,8 +956,6 @@ async fn test_remap(cx: &mut gpui::TestAppContext) { cx.simulate_keystrokes("g x"); cx.assert_state("1234fooˇ56789", Mode::Normal); - cx.executor().allow_parking(); - // test command cx.update(|cx| { cx.bind_keys([KeyBinding::new(