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: Fix can not set folder for `FileSaveDialog` (#17708)

Junkui Zhangecb7144b9571
diff --git a/crates/gpui/src/platform/windows/platform.rs b/crates/gpui/src/platform/windows/platform.rs
index d9f08c2247a..a900d0114bb 100644
--- a/crates/gpui/src/platform/windows/platform.rs
+++ b/crates/gpui/src/platform/windows/platform.rs
@@ -664,10 +664,11 @@ fn file_save_dialog(directory: PathBuf) -> Result<Option<PathBuf>> {
let dialog: IFileSaveDialog = unsafe { CoCreateInstance(&FileSaveDialog, None, CLSCTX_ALL)? };
if !directory.to_string_lossy().is_empty() {
if let Some(full_path) = directory.canonicalize().log_err() {
- let full_path = full_path.to_string_lossy().to_string();
- if !full_path.is_empty() {
+ let full_path = full_path.to_string_lossy();
+ let full_path_str = full_path.trim_start_matches("\\\\?\\");
+ if !full_path_str.is_empty() {
let path_item: IShellItem =
- unsafe { SHCreateItemFromParsingName(&HSTRING::from(&full_path), None)? };
+ unsafe { SHCreateItemFromParsingName(&HSTRING::from(full_path_str), None)? };
unsafe { dialog.SetFolder(&path_item).log_err() };
}
}