Skip to content

Commit 518061b

Browse files
committed
Clear Copilot completions upon discard
1 parent 867b5df commit 518061b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

crates/copilot/src/copilot_completion_provider.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ impl EditPredictionProvider for CopilotCompletionProvider {
196196
}
197197

198198
fn discard(&mut self, cx: &mut Context<Self>) {
199+
self.completions.clear();
200+
199201
let settings = AllLanguageSettings::get_global(cx);
200202

201203
let copilot_enabled = settings.show_edit_predictions(None, cx);
@@ -437,8 +439,16 @@ mod tests {
437439
assert_eq!(editor.display_text(cx), "one.c \ntwo\nthree\n");
438440
assert_eq!(editor.text(cx), "one.c \ntwo\nthree\n");
439441

440-
// When undoing the previously active suggestion is shown again.
442+
// When undoing the previously active suggestion isn't shown again.
441443
editor.undo(&Default::default(), window, cx);
444+
assert!(!editor.has_active_edit_prediction());
445+
assert_eq!(editor.display_text(cx), "one.c\ntwo\nthree\n");
446+
assert_eq!(editor.text(cx), "one.c\ntwo\nthree\n");
447+
448+
editor.next_edit_prediction(&Default::default(), window, cx);
449+
});
450+
executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT);
451+
cx.editor(|editor, _, cx| {
442452
assert!(editor.has_active_edit_prediction());
443453
assert_eq!(editor.display_text(cx), "one.copilot2\ntwo\nthree\n");
444454
assert_eq!(editor.text(cx), "one.c\ntwo\nthree\n");

0 commit comments

Comments
 (0)