Don't assign completion_state when completions are empty

This commit is contained in:
Nathan Sobo
2022-01-31 18:38:49 -07:00
parent 327ddbe2b4
commit 92f0491c0e
+10 -9
View File
@@ -1538,17 +1538,18 @@ impl Editor {
cx.spawn_weak(|this, mut cx| async move {
let completions = completions.await?;
if let Some(this) = cx.read(|cx| this.upgrade(cx)) {
this.update(&mut cx, |this, cx| {
this.completion_state = Some(CompletionState {
completions: completions.into(),
selected_item: 0,
list: Default::default(),
if !completions.is_empty() {
if let Some(this) = cx.read(|cx| this.upgrade(cx)) {
this.update(&mut cx, |this, cx| {
this.completion_state = Some(CompletionState {
completions: completions.into(),
selected_item: 0,
list: Default::default(),
});
cx.notify();
});
cx.notify();
});
}
}
Ok::<_, anyhow::Error>(())
})
.detach_and_log_err(cx);