mirror of
https://github.com/zed-industries/zed.git
synced 2024-09-19 02:17:35 +03:00
windows: Make "Reveal in Finder" always open the file explorer (#12207)
At the current moment, the "Reveal in Finder" behavior on Windows "opens" the file using direct execution. This causes files to be opened with whatever software they are associated with (i.e. will open Sublime Text instead of the file explorer). Release Notes: - Fixed "Reveal in Finder" on Windows to open with the File Explorer. The new behavior always opens the file explorer with the target folder/file pre-selected. https://github.com/zed-industries/zed/assets/28355157/b8ba471d-2f5b-4529-90c3-4dc59f308b99
This commit is contained in:
parent
9e3a182177
commit
9cc5ba86d1
@ -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)?;
|
||||
|
Loading…
Reference in New Issue
Block a user