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.

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

Кузнецов Максимc932dd193568
diff --git a/crates/recent_projects/src/recent_projects.rs b/crates/recent_projects/src/recent_projects.rs
index a3b51d89446..09ba8200e06 100644
--- a/crates/recent_projects/src/recent_projects.rs
+++ b/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())