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.

Fix git graph file diff view opening wrong file if a previous one is already open (#55595)

Jake Norris11f0ca5881ee
diff --git a/crates/git_ui/src/commit_view.rs b/crates/git_ui/src/commit_view.rs
index 19dea7adafe..c39c175e32c 100644
--- a/crates/git_ui/src/commit_view.rs
+++ b/crates/git_ui/src/commit_view.rs
@@ -201,7 +201,21 @@ impl CommitView {
.is_some_and(|view| view.read(cx).commit.sha == commit_sha)
});
if let Some(ix) = ix {
- pane.activate_item(ix, true, true, window, cx);
+ let existing = pane
+ .items()
+ .filter_map(|item| item.downcast::<CommitView>())
+ .find(|view| view.read(cx).commit.sha == commit_sha)
+ .unwrap();
+
+ pane.remove_item(existing.item_id(), false, false, window, cx);
+ pane.add_item(
+ Box::new(commit_view),
+ true,
+ true,
+ Some(ix),
+ window,
+ cx,
+ );
} else {
pane.add_item(Box::new(commit_view), true, true, None, window, cx);
}