Fix Copilot errors when opening buffers that don't exist locally

This commit is contained in:
Antonio Scandurra 2023-04-03 12:28:32 +02:00
parent 59fb4b3d29
commit 75ecf92ae4
2 changed files with 149 additions and 129 deletions

View file

@ -2843,14 +2843,14 @@ impl Editor {
self.copilot_state.pending_refresh = cx.spawn_weak(|this, mut cx| async move {
let (completion, completions_cycling) = copilot.update(&mut cx, |copilot, cx| {
(
copilot.completion(&buffer, buffer_position, cx),
copilot.completions(&buffer, buffer_position, cx),
copilot.completions_cycling(&buffer, buffer_position, cx),
)
});
let (completion, completions_cycling) = futures::join!(completion, completions_cycling);
let mut completions = Vec::new();
completions.extend(completion.log_err().flatten());
completions.extend(completion.log_err().into_iter().flatten());
completions.extend(completions_cycling.log_err().into_iter().flatten());
this.upgrade(&cx)?.update(&mut cx, |this, cx| {
if !completions.is_empty() {