recent_projects: Check for WSL paths in OpenFolderInWsl (#49156)

Кузнецов Максим created

Closes #42842

Previously, OpenFolderInWsl action assumed a valid path is on the host
and failed to open paths inside the WSL filesystem (accessed through
UNC)

Now the action checks for a WSL path and opens it with the appropriate
distro (skipping the choice modal)

This was manually confirmed to not regress as well as work with WSL
paths.

Code was written by hand, with extra checking by OpenAI Codex.

Release Notes:

- Fixed paths inside the WSL filesystem failing to open when using "open
folder in wsl"

Change summary

crates/recent_projects/src/recent_projects.rs | 29 +++++++++++++++++++++
1 file changed, 29 insertions(+)

Detailed changes

crates/recent_projects/src/recent_projects.rs 🔗

@@ -230,6 +230,9 @@ pub fn init(cx: &mut App) {
                 cx,
             );
 
+            let app_state = workspace.app_state().clone();
+            let window_handle = window.window_handle().downcast::<MultiWorkspace>();
+
             cx.spawn_in(window, async move |workspace, cx| {
                 use util::paths::SanitizedPath;
 
@@ -237,6 +240,32 @@ pub fn init(cx: &mut App) {
                     return;
                 };
 
+                let wsl_path = paths
+                    .iter()
+                    .find_map(util::paths::WslPath::from_path);
+
+                if let Some(util::paths::WslPath { distro, path }) = wsl_path {
+                    use remote::WslConnectionOptions;
+
+                    let connection_options = RemoteConnectionOptions::Wsl(WslConnectionOptions {
+                        distro_name: distro.to_string(),
+                        user: None,
+                    });
+
+                    let replace_window = match create_new_window {
+                        false => window_handle,
+                        true => None,
+                    };
+
+                    let open_options = workspace::OpenOptions {
+                        replace_window,
+                        ..Default::default()
+                    };
+
+                    open_remote_project(connection_options, vec![path.into()], app_state, open_options, cx).await.log_err();
+                    return;
+                }
+
                 let paths = paths
                     .into_iter()
                     .filter_map(|path| SanitizedPath::new(&path).local_to_wsl())