Clear active copilot suggestion only if there is one

This commit is contained in:
Antonio Scandurra 2023-04-03 14:32:41 +02:00
parent ec5309b543
commit b88aa9af1d

View file

@ -2922,9 +2922,11 @@ impl Editor {
fn refresh_active_copilot_suggestion(&mut self, cx: &mut ViewContext<Self>) {
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::<usize>(None, cx));
cx.notify();
} else if let Some(text) = self
.copilot_state
.text_for_active_completion(cursor, &snapshot)
@ -2938,12 +2940,13 @@ impl Editor {
cx,
)
});
} else {
cx.notify();
} else if self.has_active_copilot_suggestion(cx) {
self.display_map
.update(cx, |map, cx| map.replace_suggestion::<usize>(None, cx));
}
cx.notify();
}
}
fn accept_copilot_suggestion(&mut self, cx: &mut ViewContext<Self>) -> bool {
let snapshot = self.buffer.read(cx).snapshot(cx);