Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

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

Antonio Scandurra7a05db6d3daf
diff --git a/crates/assistant/src/inline_assistant.rs b/crates/assistant/src/inline_assistant.rs
index c51afd8ba22..133b045fca5 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<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);
+ }
+ }
+ _ => {}
}
}