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 weird behavior when save replaces the existing open file (#17123)

CharlesChen08239c8b6f4a9f9f
diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs
index 84c404c9f65..e8ac67b0e05 100644
--- a/crates/workspace/src/pane.rs
+++ b/crates/workspace/src/pane.rs
@@ -1556,8 +1556,16 @@ impl Pane {
.update(cx, |workspace, cx| workspace.prompt_for_new_path(cx))
})??;
if let Some(abs_path) = abs_path.await.ok().flatten() {
- pane.update(cx, |_, cx| item.save_as(project, abs_path, cx))?
- .await?;
+ pane.update(cx, |pane, cx| {
+ if let Some(item) = pane.item_for_path(abs_path.clone(), cx) {
+ if let Some(idx) = pane.index_for_item(&*item) {
+ pane.remove_item(idx, false, false, cx);
+ }
+ }
+
+ item.save_as(project, abs_path, cx)
+ })?
+ .await?;
} else {
return Ok(false);
}