Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

windows: Make "Reveal in Finder" always open the file explorer (#12207)

Robert Borghese9cc5ba86d1b7
diff --git a/crates/gpui/src/platform/windows/platform.rs b/crates/gpui/src/platform/windows/platform.rs
index 0b0c6ad3c28..5333682fad4 100644
--- a/crates/gpui/src/platform/windows/platform.rs
+++ b/crates/gpui/src/platform/windows/platform.rs
@@ -435,7 +435,7 @@ impl Platform for WindowsPlatform {
if path.is_empty() {
return;
}
- open_target(path);
+ open_target_in_explorer(path);
})
.detach();
}
@@ -734,6 +734,25 @@ fn open_target(target: &str) {
}
}
+fn open_target_in_explorer(target: &str) {
+ unsafe {
+ let ret = ShellExecuteW(
+ None,
+ windows::core::w!("open"),
+ windows::core::w!("explorer.exe"),
+ &HSTRING::from(format!("/select,{}", target).as_str()),
+ None,
+ SW_SHOWDEFAULT,
+ );
+ if ret.0 <= 32 {
+ log::error!(
+ "Unable to open target in explorer: {}",
+ std::io::Error::last_os_error()
+ );
+ }
+ }
+}
+
unsafe fn show_savefile_dialog(directory: PathBuf) -> Result<IFileSaveDialog> {
let dialog: IFileSaveDialog = CoCreateInstance(&FileSaveDialog, None, CLSCTX_ALL)?;
let bind_context = CreateBindCtx(0)?;