From 89ddf14b0ef754e11dee8be86d968770dc4255d9 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Thu, 23 Feb 2023 21:36:17 -0800 Subject: [PATCH] Remove borrow from reveal_path() --- crates/gpui/src/app.rs | 2 +- crates/gpui/src/platform/mac.rs | 8 ++----- crates/gpui/src/platform/mac/platform.rs | 27 ++++++++---------------- 3 files changed, 12 insertions(+), 25 deletions(-) diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rs index 35c91f1ff2..286bf57a46 100644 --- a/crates/gpui/src/app.rs +++ b/crates/gpui/src/app.rs @@ -191,7 +191,7 @@ impl App { pub fn new(asset_source: impl AssetSource) -> Result { let platform = platform::current::platform(); let foreground = Rc::new(executor::Foreground::platform(platform.dispatcher())?); - let foreground_platform = platform::current::foreground_platform(foreground.clone()); + let foreground_platform = platform::current::foreground_platform(); let app = Self(Rc::new(RefCell::new(MutableAppContext::new( foreground, Arc::new(executor::Background::new()), diff --git a/crates/gpui/src/platform/mac.rs b/crates/gpui/src/platform/mac.rs index 342c1c66d0..3e31c137ec 100644 --- a/crates/gpui/src/platform/mac.rs +++ b/crates/gpui/src/platform/mac.rs @@ -23,16 +23,12 @@ pub use renderer::Surface; use std::{ops::Range, rc::Rc, sync::Arc}; use window::Window; -use crate::executor; - pub(crate) fn platform() -> Arc { Arc::new(MacPlatform::new()) } -pub(crate) fn foreground_platform( - foreground: Rc, -) -> Rc { - Rc::new(MacForegroundPlatform::new(foreground)) +pub(crate) fn foreground_platform() -> Rc { + Rc::new(MacForegroundPlatform::new()) } trait BoolExt { diff --git a/crates/gpui/src/platform/mac/platform.rs b/crates/gpui/src/platform/mac/platform.rs index aeec02c8ca..b98471a6ac 100644 --- a/crates/gpui/src/platform/mac/platform.rs +++ b/crates/gpui/src/platform/mac/platform.rs @@ -152,11 +152,10 @@ pub struct MacForegroundPlatformState { open_urls: Option)>>, finish_launching: Option>, menu_actions: Vec>, - foreground: Rc, } impl MacForegroundPlatform { - pub fn new(foreground: Rc) -> Self { + pub fn new() -> Self { Self(RefCell::new(MacForegroundPlatformState { become_active: Default::default(), resign_active: Default::default(), @@ -168,7 +167,6 @@ impl MacForegroundPlatform { open_urls: Default::default(), finish_launching: Default::default(), menu_actions: Default::default(), - foreground, })) } @@ -456,21 +454,14 @@ impl platform::ForegroundPlatform for MacForegroundPlatform { fn reveal_path(&self, path: &Path) { unsafe { - let path = path.to_path_buf(); - self.0 - .borrow() - .foreground - .spawn(async move { - let full_path = ns_string(path.to_str().unwrap_or("")); - let root_full_path = ns_string(""); - let workspace: id = msg_send![class!(NSWorkspace), sharedWorkspace]; - let _: BOOL = msg_send![ - workspace, - selectFile: full_path - inFileViewerRootedAtPath: root_full_path - ]; - }) - .detach(); + let full_path = ns_string(path.to_str().unwrap_or("")); + let root_full_path = ns_string(""); + let workspace: id = msg_send![class!(NSWorkspace), sharedWorkspace]; + let _: BOOL = msg_send![ + workspace, + selectFile: full_path + inFileViewerRootedAtPath: root_full_path + ]; } } }