diff --git a/crates/git_ui/src/branch_picker.rs b/crates/git_ui/src/branch_picker.rs index b9a8dfea9ea167bf7ee807ee2b459444f4fa4f4d..7a046266ac863f78c1e449c7c1b58f0834834b2c 100644 --- a/crates/git_ui/src/branch_picker.rs +++ b/crates/git_ui/src/branch_picker.rs @@ -137,13 +137,13 @@ impl BranchList { }) .await; - this.update_in(cx, |this, window, cx| { + let _ = this.update_in(cx, |this, window, cx| { this.picker.update(cx, |picker, cx| { picker.delegate.default_branch = default_branch; picker.delegate.all_branches = Some(all_branches); picker.refresh(window, cx); }) - })?; + }); anyhow::Ok(()) }) @@ -410,37 +410,20 @@ impl PickerDelegate for BranchListDelegate { return; } - cx.spawn_in(window, { - let branch = entry.branch.clone(); - async move |picker, cx| { - let branch_change_task = picker.update(cx, |this, cx| { - let repo = this - .delegate - .repo - .as_ref() - .context("No active repository")? - .clone(); - - let mut cx = cx.to_async(); - - anyhow::Ok(async move { - repo.update(&mut cx, |repo, _| { - repo.change_branch(branch.name().to_string()) - })? - .await? - }) - })??; - - branch_change_task.await?; + let Some(repo) = self.repo.clone() else { + return; + }; - picker.update(cx, |_, cx| { - cx.emit(DismissEvent); + let branch = entry.branch.clone(); + cx.spawn(async move |_, cx| { + repo.update(cx, |repo, _| repo.change_branch(branch.name().to_string()))? + .await??; - anyhow::Ok(()) - }) - } + anyhow::Ok(()) }) .detach_and_prompt_err("Failed to change branch", window, cx, |_, _, _| None); + + cx.emit(DismissEvent); } fn dismissed(&mut self, _: &mut Window, cx: &mut Context>) {