From b88aa9af1de418d671be798a06a64ab51df4608f Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Mon, 3 Apr 2023 14:32:41 +0200 Subject: [PATCH] Clear active copilot suggestion only if there is one --- crates/editor/src/editor.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 0d365aee50..7a8293e195 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -2922,9 +2922,11 @@ impl Editor { fn refresh_active_copilot_suggestion(&mut self, cx: &mut ViewContext) { let snapshot = self.buffer.read(cx).snapshot(cx); let cursor = self.selections.newest_anchor().head(); + if self.context_menu.is_some() { self.display_map .update(cx, |map, cx| map.replace_suggestion::(None, cx)); + cx.notify(); } else if let Some(text) = self .copilot_state .text_for_active_completion(cursor, &snapshot) @@ -2938,11 +2940,12 @@ impl Editor { cx, ) }); - } else { + cx.notify(); + } else if self.has_active_copilot_suggestion(cx) { self.display_map .update(cx, |map, cx| map.replace_suggestion::(None, cx)); + cx.notify(); } - cx.notify(); } fn accept_copilot_suggestion(&mut self, cx: &mut ViewContext) -> bool {