@@ -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<Picker<Self>>) {