Revert "Remove borrow from reveal_path()"

This commit is contained in:
Mikayla Maki 2023-02-24 09:39:52 -08:00 committed by GitHub
parent 2ec25bef84
commit 8656708de4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 12 deletions

View file

@ -152,10 +152,11 @@ pub struct MacForegroundPlatformState {
open_urls: Option<Box<dyn FnMut(Vec<String>)>>,
finish_launching: Option<Box<dyn FnOnce()>>,
menu_actions: Vec<Box<dyn Action>>,
foreground: Rc<executor::Foreground>,
}
impl MacForegroundPlatform {
pub fn new() -> Self {
pub fn new(foreground: Rc<executor::Foreground>) -> Self {
Self(RefCell::new(MacForegroundPlatformState {
become_active: Default::default(),
resign_active: Default::default(),
@ -167,6 +168,7 @@ impl MacForegroundPlatform {
open_urls: Default::default(),
finish_launching: Default::default(),
menu_actions: Default::default(),
foreground,
}))
}
@ -454,14 +456,21 @@ impl platform::ForegroundPlatform for MacForegroundPlatform {
fn reveal_path(&self, path: &Path) {
unsafe {
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
];
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();
}
}
}