Assistant: propagate cancel action if there is no pending inline assist (#2923)

Release Notes:

- Fixed a bug where modals could not be dismissed with `escape` when
certain views were active in the workspace (preview only).
This commit is contained in:
Max Brunsfeld 2023-08-31 11:17:09 -07:00 committed by GitHub
commit 00aae5abee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -406,20 +406,11 @@ impl AssistantPanel {
_: &editor::Cancel, _: &editor::Cancel,
cx: &mut ViewContext<Workspace>, cx: &mut ViewContext<Workspace>,
) { ) {
let panel = if let Some(panel) = workspace.panel::<AssistantPanel>(cx) { if let Some(panel) = workspace.panel::<AssistantPanel>(cx) {
panel if let Some(editor) = workspace
} else {
return;
};
let editor = if let Some(editor) = workspace
.active_item(cx) .active_item(cx)
.and_then(|item| item.downcast::<Editor>()) .and_then(|item| item.downcast::<Editor>())
{ {
editor
} else {
return;
};
let handled = panel.update(cx, |panel, cx| { let handled = panel.update(cx, |panel, cx| {
if let Some(assist_id) = panel if let Some(assist_id) = panel
.pending_inline_assist_ids_by_editor .pending_inline_assist_ids_by_editor
@ -432,11 +423,14 @@ impl AssistantPanel {
false false
} }
}); });
if handled {
if !handled { return;
cx.propagate_action();
} }
} }
}
cx.propagate_action();
}
fn close_inline_assist(&mut self, assist_id: usize, undo: bool, cx: &mut ViewContext<Self>) { fn close_inline_assist(&mut self, assist_id: usize, undo: bool, cx: &mut ViewContext<Self>) {
self.hide_inline_assist(assist_id, cx); self.hide_inline_assist(assist_id, cx);