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
This commit is contained in:
张小白 2024-10-14 23:23:16 +08:00 committed by GitHub
parent 7d5fe66b54
commit 3ff52a816e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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::<FuturesUnordered<_>>();
#[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::<FuturesUnordered<_>>();
while let Some((path, metadata)) = fetch_metadata_tasks.next().await {
if let Some(metadata) = metadata {
paths_with_metadata.push((path, metadata));