Notify on opening WSL paths outside of wsl (#40195)

Closes #27340

Release Notes:

- N/A

---------

Co-authored-by: John Tur <john-tur@outlook.com>
This commit is contained in:
Julia Ryan
2025-10-25 01:44:32 +00:00
committed by GitHub
co-authored by John Tur
parent 1dffdea27c
commit 7433d85458
11 changed files with 250 additions and 72 deletions
+36 -2
View File
@@ -7318,6 +7318,10 @@ pub fn open_paths(
let mut existing = None;
let mut best_match = None;
let mut open_visible = OpenVisible::All;
#[cfg(target_os = "windows")]
let wsl_path = abs_paths
.iter()
.find_map(|p| util::paths::WslPath::from_path(p));
cx.spawn(async move |cx| {
if open_options.open_new_workspace != Some(true) {
@@ -7381,7 +7385,7 @@ pub fn open_paths(
}
}
if let Some(existing) = existing {
let result = if let Some(existing) = existing {
let open_task = existing
.update(cx, |workspace, window, cx| {
window.activate_window();
@@ -7418,7 +7422,37 @@ pub fn open_paths(
)
})?
.await
}
};
#[cfg(target_os = "windows")]
if let Some(util::paths::WslPath{distro, path}) = wsl_path
&& let Ok((workspace, _)) = &result
{
workspace
.update(cx, move |workspace, _window, cx| {
struct OpenInWsl;
workspace.show_notification(NotificationId::unique::<OpenInWsl>(), cx, move |cx| {
let display_path = util::markdown::MarkdownInlineCode(&path.to_string_lossy());
let msg = format!("{display_path} is inside a WSL filesystem, some features may not work unless you open it with WSL remote");
cx.new(move |cx| {
MessageNotification::new(msg, cx)
.primary_message("Open in WSL")
.primary_icon(IconName::FolderOpen)
.primary_on_click(move |window, cx| {
window.dispatch_action(Box::new(remote::OpenWslPath {
distro: remote::WslConnectionOptions {
distro_name: distro.clone(),
user: None,
},
paths: vec![path.clone().into()],
}), cx)
})
})
});
})
.unwrap();
};
result
})
}