Skip to content

Commit

Permalink
git_ui: Combine disjoint conditions into one (#25722)
Browse files Browse the repository at this point in the history
This PR combines two disjoint conditions for the same value into one.

This makes it so the type checker can accurately reason about the
branches.

Release Notes:

- N/A
  • Loading branch information
maxdeviant authored Feb 27, 2025
1 parent 81badd1 commit 3505a17
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions crates/git_ui/src/branch_picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,26 +141,24 @@ impl Render for BranchList {
fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
v_flex()
.w(rems(self.rem_width))
.when_some(self.picker.clone(), |div, picker| {
div.child(picker.clone()).on_mouse_down_out({
.map(|parent| match self.picker.as_ref() {
Some(picker) => parent.child(picker.clone()).on_mouse_down_out({
let picker = picker.clone();
cx.listener(move |_, _, window, cx| {
picker.update(cx, |this, cx| {
this.cancel(&Default::default(), window, cx);
})
})
})
})
.when_none(&self.picker, |div| {
div.child(
}),
None => parent.child(
h_flex()
.id("branch-picker-error")
.on_click(
cx.listener(|this, _, window, cx| this.reload_branches(window, cx)),
)
.child("Could not load branches.")
.child("Click to retry"),
)
),
})
}
}
Expand Down

0 comments on commit 3505a17

Please sign in to comment.