Skip to content

Commit 88914dc

Browse files
committed
Fix deduping
1 parent f42fd49 commit 88914dc

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/git_ui/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ multi_buffer.workspace = true
4444
notifications.workspace = true
4545
panel.workspace = true
4646
picker.workspace = true
47-
postage.workspace = true
4847
project.workspace = true
4948
schemars.workspace = true
5049
serde.workspace = true

crates/git_ui/src/project_diff.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,17 @@ impl ProjectDiff {
101101
window: &mut Window,
102102
cx: &mut Context<Workspace>,
103103
) {
104+
telemetry::event!("Git Branch Diff Opened");
104105
let project = workspace.project().clone();
106+
107+
let existing = workspace
108+
.items_of_type::<Self>(cx)
109+
.find(|item| matches!(item.read(cx).diff_base(cx), DiffBase::Merge { .. }));
110+
if let Some(existing) = existing {
111+
workspace.activate_item(&existing, true, true, window, cx);
112+
return;
113+
}
105114
let workspace = cx.entity();
106-
// todo!() only open one at a time
107115
window
108116
.spawn(cx, async move |cx| {
109117
let this = cx
@@ -135,8 +143,10 @@ impl ProjectDiff {
135143
"Action"
136144
}
137145
);
138-
// todo!() don't de-dupe with the branch diff
139-
let project_diff = if let Some(existing) = workspace.item_of_type::<Self>(cx) {
146+
let existing = workspace
147+
.items_of_type::<Self>(cx)
148+
.find(|item| matches!(item.read(cx).diff_base(cx), DiffBase::Head));
149+
let project_diff = if let Some(existing) = existing {
140150
workspace.activate_item(&existing, true, true, window, cx);
141151
existing
142152
} else {

crates/project/src/git_store/branch_diff.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,6 @@ impl BranchDiff {
360360
}
361361
}
362362

363-
// HEAD and working tree are the same
364-
// but merge base and HEAD diff
365-
// todo!() is this right...?
366363
fn diff_status_to_file_status(branch_diff: &git::status::TreeDiffStatus) -> FileStatus {
367364
let file_status = match branch_diff {
368365
git::status::TreeDiffStatus::Added { .. } => FileStatus::Tracked(TrackedStatus {

0 commit comments

Comments
 (0)