From 6c931ab9da7f73344fd2698b237a1d31483cdeb1 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Mon, 1 May 2023 16:49:17 +0200 Subject: [PATCH] Inline test-only `AppContext` methods --- crates/gpui/src/app.rs | 15 --------------- crates/gpui/src/app/test_app_context.rs | 12 +++++++----- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rs index c757e7f383..589ec8f1af 100644 --- a/crates/gpui/src/app.rs +++ b/crates/gpui/src/app.rs @@ -1062,10 +1062,6 @@ impl AppContext { } } - fn dispatch_global_action(&mut self, action: A) { - self.dispatch_global_action_any(&action); - } - fn dispatch_global_action_any(&mut self, action: &dyn Action) -> bool { self.update(|this| { if let Some((name, mut handler)) = this.global_actions.remove_entry(&action.id()) { @@ -1907,17 +1903,6 @@ impl AppContext { }); } - fn handle_dispatch_action_from_effect( - &mut self, - window_id: usize, - view_id: Option, - action: &dyn Action, - ) { - self.update_window(window_id, |cx| { - cx.handle_dispatch_action_from_effect(view_id, action) - }); - } - fn handle_action_dispatch_notification_effect(&mut self, action_id: TypeId) { self.action_dispatch_observations .clone() diff --git a/crates/gpui/src/app/test_app_context.rs b/crates/gpui/src/app/test_app_context.rs index 3a03a81c47..79f35cd923 100644 --- a/crates/gpui/src/app/test_app_context.rs +++ b/crates/gpui/src/app/test_app_context.rs @@ -72,14 +72,16 @@ impl TestAppContext { } pub fn dispatch_action(&self, window_id: usize, action: A) { - let mut cx = self.cx.borrow_mut(); - if let Some(view_id) = cx.windows.get(&window_id).and_then(|w| w.focused_view_id) { - cx.handle_dispatch_action_from_effect(window_id, Some(view_id), &action); - } + self.cx + .borrow_mut() + .update_window(window_id, |window| { + window.handle_dispatch_action_from_effect(window.focused_view_id(), &action); + }) + .expect("window not found"); } pub fn dispatch_global_action(&self, action: A) { - self.cx.borrow_mut().dispatch_global_action(action); + self.cx.borrow_mut().dispatch_global_action_any(&action); } pub fn dispatch_keystroke(&mut self, window_id: usize, keystroke: Keystroke, is_held: bool) {