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

Release Notes:

- N/A
This commit is contained in:
Antonio Scandurra 2024-06-05 16:31:45 +02:00 committed by GitHub
parent 3587e9726b
commit 7a05db6d3d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -697,10 +697,18 @@ impl InlineAssistEditor {
event: &EditorEvent, event: &EditorEvent,
cx: &mut ViewContext<Self>, cx: &mut ViewContext<Self>,
) { ) {
if let EditorEvent::Edited = event { match event {
EditorEvent::Edited => {
self.pending_prompt = self.prompt_editor.read(cx).text(cx); self.pending_prompt = self.prompt_editor.read(cx).text(cx);
cx.notify(); cx.notify();
} }
EditorEvent::Blurred => {
if !self.confirmed {
cx.emit(InlineAssistEditorEvent::Canceled);
}
}
_ => {}
}
} }
fn handle_codegen_changed(&mut self, _: Model<Codegen>, cx: &mut ViewContext<Self>) { fn handle_codegen_changed(&mut self, _: Model<Codegen>, cx: &mut ViewContext<Self>) {