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.

workspace: Fix toolchain not recovered correctly in remote development (#60030)

Xin Zhaofebe242c0bf7
diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs
index ace71b3de14..699e1ca5831 100644
--- a/crates/workspace/src/workspace.rs
+++ b/crates/workspace/src/workspace.rs
@@ -10809,28 +10809,6 @@ async fn open_remote_project_inner(
source_workspace: Option<WeakEntity<Workspace>>,
cx: &mut AsyncApp,
) -> Result<Vec<Option<Box<dyn ItemHandle>>>> {
- let db = cx.update(|cx| WorkspaceDb::global(cx));
- let toolchains = db.toolchains(workspace_id).await?;
- for (toolchain, worktree_path, path) in toolchains {
- project
- .update(cx, |this, cx| {
- let Some(worktree_id) =
- this.find_worktree(&worktree_path, cx)
- .and_then(|(worktree, rel_path)| {
- if rel_path.is_empty() {
- Some(worktree.read(cx).id())
- } else {
- None
- }
- })
- else {
- return Task::ready(None);
- };
-
- this.activate_toolchain(ProjectPath { worktree_id, path }, toolchain, cx)
- })
- .await;
- }
let mut project_paths_to_open = vec![];
let mut project_path_errors = vec![];
@@ -10856,8 +10834,13 @@ async fn open_remote_project_inner(
let workspace = window.update(cx, |multi_workspace, window, cx| {
let new_workspace = cx.new(|cx| {
- let mut workspace =
- Workspace::new(Some(workspace_id), project, app_state.clone(), window, cx);
+ let mut workspace = Workspace::new(
+ Some(workspace_id),
+ project.clone(),
+ app_state.clone(),
+ window,
+ cx,
+ );
workspace.update_history(cx);
if let Some(ref serialized) = serialized_workspace {
@@ -10880,6 +10863,29 @@ async fn open_remote_project_inner(
new_workspace
})?;
+ let db = cx.update(|cx| WorkspaceDb::global(cx));
+ let toolchains = db.toolchains(workspace_id).await?;
+ for (toolchain, worktree_path, path) in toolchains {
+ project
+ .update(cx, |this, cx| {
+ let Some(worktree_id) =
+ this.find_worktree(&worktree_path, cx)
+ .and_then(|(worktree, rel_path)| {
+ if rel_path.is_empty() {
+ Some(worktree.read(cx).id())
+ } else {
+ None
+ }
+ })
+ else {
+ return Task::ready(None);
+ };
+
+ this.activate_toolchain(ProjectPath { worktree_id, path }, toolchain, cx)
+ })
+ .await;
+ }
+
let items = window
.update(cx, |_, window, cx| {
window.activate_window();