mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-08 07:35:01 +03:00
workspace: Fix weird behavior when save replaces the existing open file (#17123)
Fixes this weird behavior: - open an file, like `test.rs` - `ctrl-n` create an new buffer - `ctrl-s` save new buffer with name `test.rs`, select replace old file. - the older open file also exist, this is weird. Release Notes: - Fixed two panes staying opening when saving a new buffer with the same filename as a file that was already open.
This commit is contained in:
parent
7cc24eaf4b
commit
9c8b6f4a9f
@ -1556,7 +1556,15 @@ 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))?
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user