Cancel inline assist editor on blur if it wasn't confirmed (#12684)

Antonio Scandurra created

Release Notes:

- N/A

Change summary

crates/assistant/src/inline_assistant.rs | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)

Detailed changes

crates/assistant/src/inline_assistant.rs 🔗

@@ -697,9 +697,17 @@ impl InlineAssistEditor {
         event: &EditorEvent,
         cx: &mut ViewContext<Self>,
     ) {
-        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);
+                }
+            }
+            _ => {}
         }
     }