windows: Add support for SSH (#29145)

Closes #19892

This PR builds on top of #20587 and improves upon it.

Release Notes:

- N/A

---------

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
This commit is contained in:
张小白 2025-07-08 22:34:57 +08:00 committed by GitHub
parent 8bd739d869
commit 0ca0914cca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 1435 additions and 354 deletions

View file

@ -117,7 +117,7 @@ use text::{Anchor, BufferId, Point};
use toolchain_store::EmptyToolchainStore;
use util::{
ResultExt as _,
paths::{SanitizedPath, compare_paths},
paths::{PathStyle, RemotePathBuf, SanitizedPath, compare_paths},
};
use worktree::{CreatedEntry, Snapshot, Traversal};
pub use worktree::{
@ -1159,9 +1159,11 @@ impl Project {
let snippets =
SnippetProvider::new(fs.clone(), BTreeSet::from_iter([global_snippets_dir]), cx);
let ssh_proto = ssh.read(cx).proto_client();
let worktree_store =
cx.new(|_| WorktreeStore::remote(false, ssh_proto.clone(), SSH_PROJECT_ID));
let (ssh_proto, path_style) =
ssh.read_with(cx, |ssh, _| (ssh.proto_client(), ssh.path_style()));
let worktree_store = cx.new(|_| {
WorktreeStore::remote(false, ssh_proto.clone(), SSH_PROJECT_ID, path_style)
});
cx.subscribe(&worktree_store, Self::on_worktree_store_event)
.detach();
@ -1410,8 +1412,15 @@ impl Project {
let remote_id = response.payload.project_id;
let role = response.payload.role();
// todo(zjk)
// Set the proper path style based on the remote
let worktree_store = cx.new(|_| {
WorktreeStore::remote(true, client.clone().into(), response.payload.project_id)
WorktreeStore::remote(
true,
client.clone().into(),
response.payload.project_id,
PathStyle::Posix,
)
})?;
let buffer_store = cx.new(|cx| {
BufferStore::remote(worktree_store.clone(), client.clone().into(), remote_id, cx)
@ -4039,7 +4048,8 @@ impl Project {
})
})
} else if let Some(ssh_client) = self.ssh_client.as_ref() {
let request_path = Path::new(path);
let path_style = ssh_client.read(cx).path_style();
let request_path = RemotePathBuf::from_str(path, path_style);
let request = ssh_client
.read(cx)
.proto_client()