ssh project: Handle multiple paths and worktrees correctly (#18277)

This makes SSH projects work with `ssh_connections` that have multiple
paths:

```json
{
  "ssh_connections": [
    {
      "host": "127.0.0.1",
      "projects": [
        {
          "paths": [
            "/Users/thorstenball/work/projs/go-proj",
            "/Users/thorstenball/work/projs/rust-proj"
          ]
        }
      ]
    }
  ]
}
```

@ConradIrwin @mikayla-maki since this wasn't really released yet, we
didn't create a full-on migration, so old ssh projects that were already
serialized need to either be manually deleted from the database, or the
whole local DB wiped.

Release Notes:

- N/A

---------

Co-authored-by: Bennet <bennet@zed.dev>
This commit is contained in:
Thorsten Ball 2024-09-24 16:46:11 +02:00 committed by GitHub
parent 3a2f0653d1
commit 437bcc0ce6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 66 additions and 56 deletions

View file

@ -268,7 +268,7 @@ impl PickerDelegate for RecentProjectsDelegate {
.as_ref()
.map(|port| port.to_string())
.unwrap_or_default(),
ssh_project.path,
ssh_project.paths.join(","),
ssh_project
.user
.as_ref()
@ -403,7 +403,7 @@ impl PickerDelegate for RecentProjectsDelegate {
password: None,
};
let paths = vec![PathBuf::from(ssh_project.path.clone())];
let paths = ssh_project.paths.iter().map(PathBuf::from).collect();
cx.spawn(|_, mut cx| async move {
open_ssh_project(connection_options, paths, app_state, open_options, &mut cx).await
@ -460,9 +460,7 @@ impl PickerDelegate for RecentProjectsDelegate {
.filter_map(|i| paths.paths().get(*i).cloned())
.collect(),
),
SerializedWorkspaceLocation::Ssh(ssh_project) => {
Arc::new(vec![PathBuf::from(ssh_project.ssh_url())])
}
SerializedWorkspaceLocation::Ssh(ssh_project) => Arc::new(ssh_project.ssh_urls()),
SerializedWorkspaceLocation::DevServer(dev_server_project) => {
Arc::new(vec![PathBuf::from(format!(
"{}:{}",