From 7a05db6d3dafb84ef571c46d70a8572ab3ce4236 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 5 Jun 2024 16:31:45 +0200 Subject: [PATCH] Cancel inline assist editor on blur if it wasn't confirmed (#12684) Release Notes: - N/A --- crates/assistant/src/inline_assistant.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/crates/assistant/src/inline_assistant.rs b/crates/assistant/src/inline_assistant.rs index c51afd8ba2..133b045fca 100644 --- a/crates/assistant/src/inline_assistant.rs +++ b/crates/assistant/src/inline_assistant.rs @@ -697,9 +697,17 @@ impl InlineAssistEditor { event: &EditorEvent, cx: &mut ViewContext, ) { - if let EditorEvent::Edited = event { - self.pending_prompt = self.prompt_editor.read(cx).text(cx); - cx.notify(); + match event { + EditorEvent::Edited => { + self.pending_prompt = self.prompt_editor.read(cx).text(cx); + cx.notify(); + } + EditorEvent::Blurred => { + if !self.confirmed { + cx.emit(InlineAssistEditorEvent::Canceled); + } + } + _ => {} } }