From 3ff52a816e4aaead85a085f5aad1a086a3318be6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=B0=8F=E7=99=BD?= <364772080@qq.com> Date: Mon, 14 Oct 2024 23:23:16 +0800 Subject: [PATCH] windows: Fix opening wrong path when clicking path in the terminal view (#18726) Closes #18550 This PR removes the prefix `\\?\`. https://github.com/user-attachments/assets/f4f4333c-5d87-4f0f-b12c-fb2108703b6a Release Notes: - N/A --- crates/terminal_view/src/terminal_view.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/crates/terminal_view/src/terminal_view.rs b/crates/terminal_view/src/terminal_view.rs index 28a3d61d65..b2cbae0dfe 100644 --- a/crates/terminal_view/src/terminal_view.rs +++ b/crates/terminal_view/src/terminal_view.rs @@ -798,6 +798,7 @@ fn possible_open_paths_metadata( cx.background_executor().spawn(async move { let mut paths_with_metadata = Vec::with_capacity(potential_paths.len()); + #[cfg(not(target_os = "windows"))] let mut fetch_metadata_tasks = potential_paths .into_iter() .map(|potential_path| async { @@ -813,6 +814,20 @@ fn possible_open_paths_metadata( }) .collect::>(); + #[cfg(target_os = "windows")] + let mut fetch_metadata_tasks = potential_paths + .iter() + .map(|potential_path| async { + let metadata = fs.metadata(potential_path).await.ok().flatten(); + let path = PathBuf::from( + potential_path + .to_string_lossy() + .trim_start_matches("\\\\?\\"), + ); + (PathWithPosition { path, row, column }, metadata) + }) + .collect::>(); + while let Some((path, metadata)) = fetch_metadata_tasks.next().await { if let Some(metadata) = metadata { paths_with_metadata.push((path, metadata));