From eecd4e39ccb876cf4bed056385165c5e1a36e772 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Thu, 31 Aug 2023 11:09:36 -0700 Subject: [PATCH] Propagate Cancel action if there is no pending inline assist --- crates/ai/src/assistant.rs | 48 +++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 27 deletions(-) diff --git a/crates/ai/src/assistant.rs b/crates/ai/src/assistant.rs index 2aaf75ae39..5cde99af82 100644 --- a/crates/ai/src/assistant.rs +++ b/crates/ai/src/assistant.rs @@ -406,36 +406,30 @@ impl AssistantPanel { _: &editor::Cancel, cx: &mut ViewContext, ) { - let panel = if let Some(panel) = workspace.panel::(cx) { - panel - } else { - return; - }; - let editor = if let Some(editor) = workspace - .active_item(cx) - .and_then(|item| item.downcast::()) - { - editor - } else { - return; - }; - - let handled = panel.update(cx, |panel, cx| { - if let Some(assist_id) = panel - .pending_inline_assist_ids_by_editor - .get(&editor.downgrade()) - .and_then(|assist_ids| assist_ids.last().copied()) + if let Some(panel) = workspace.panel::(cx) { + if let Some(editor) = workspace + .active_item(cx) + .and_then(|item| item.downcast::()) { - panel.close_inline_assist(assist_id, true, cx); - true - } else { - false + let handled = panel.update(cx, |panel, cx| { + if let Some(assist_id) = panel + .pending_inline_assist_ids_by_editor + .get(&editor.downgrade()) + .and_then(|assist_ids| assist_ids.last().copied()) + { + panel.close_inline_assist(assist_id, true, cx); + true + } else { + false + } + }); + if handled { + return; + } } - }); - - if !handled { - cx.propagate_action(); } + + cx.propagate_action(); } fn close_inline_assist(&mut self, assist_id: usize, undo: bool, cx: &mut ViewContext) {