ssh: Fix abs paths in file history & repeated go-to-def (#19027)

This fixes two things:

- Go-to-def to absolute paths (i.e. opening stdlib files) multiple times
(opening, dropping, and re-opening worktrees)
- Re-opening abs paths from the file picker history that were added
there by go-to-def


Release Notes:

- N/A

---------

Co-authored-by: Bennet <bennet@zed.dev>
This commit is contained in:
Thorsten Ball 2024-10-11 11:21:34 +02:00 committed by GitHub
parent 4726f30bd6
commit 1691652948
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 145 additions and 74 deletions

View file

@ -237,10 +237,13 @@ impl WorktreeStore {
.to_string_lossy()
.to_string();
cx.spawn(|this, mut cx| async move {
let this = this.upgrade().context("Dropped worktree store")?;
let response = client
.request(proto::AddWorktree {
project_id: SSH_PROJECT_ID,
path: abs_path.clone(),
visible,
})
.await?;
@ -252,7 +255,7 @@ impl WorktreeStore {
let worktree = cx.update(|cx| {
Worktree::remote(
0,
SSH_PROJECT_ID,
0,
proto::WorktreeMetadata {
id: response.worktree_id,
@ -509,11 +512,6 @@ impl WorktreeStore {
for worktree in &self.worktrees {
if let Some(worktree) = worktree.upgrade() {
worktree.update(cx, |worktree, _| {
println!(
"worktree. is_local: {:?}, is_remote: {:?}",
worktree.is_local(),
worktree.is_remote()
);
if let Some(worktree) = worktree.as_remote_mut() {
worktree.disconnected_from_host();
}