From 92f0491c0ee625801f874bce21d7effacd825cf9 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Mon, 31 Jan 2022 18:38:49 -0700 Subject: [PATCH] Don't assign completion_state when completions are empty --- crates/editor/src/editor.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 1f892369eee35ef86bcc0e93521083077867f2aa..c01383bb8aba952bf5277c2c73e02ef47ec97bed 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -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);