From 88ddd7be467d4a42af1c533cccde588e18ef090e Mon Sep 17 00:00:00 2001 From: Bennet Bo Fenner Date: Wed, 16 Apr 2025 20:32:08 +0200 Subject: [PATCH] agent: Allow quoting selection when text thread is active (#28887) This makes the `assistant: Quote selection` work again for text threads. Next up is supporting this also in normal threads. Release Notes: - agent: Add support for inserting selections (assistant: Quote selection) into text threads --- crates/agent/src/assistant_panel.rs | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/crates/agent/src/assistant_panel.rs b/crates/agent/src/assistant_panel.rs index 278d131d936e37955d58e37f1148d9c49302658b..b73a10bdb0eb40b426019df6bb0dc74f43b8c1a8 100644 --- a/crates/agent/src/assistant_panel.rs +++ b/crates/agent/src/assistant_panel.rs @@ -1788,10 +1788,27 @@ impl AssistantPanelDelegate for ConcreteAssistantPanelDelegate { fn quote_selection( &self, - _workspace: &mut Workspace, - _creases: Vec<(String, String)>, - _window: &mut Window, - _cx: &mut Context, + workspace: &mut Workspace, + creases: Vec<(String, String)>, + window: &mut Window, + cx: &mut Context, ) { + let Some(panel) = workspace.panel::(cx) else { + return; + }; + + if !panel.focus_handle(cx).contains_focused(window, cx) { + workspace.toggle_panel_focus::(window, cx); + } + + panel.update(cx, |_, cx| { + // Wait to create a new context until the workspace is no longer + // being updated. + cx.defer_in(window, move |panel, window, cx| { + if let Some(context) = panel.active_context_editor() { + context.update(cx, |context, cx| context.quote_creases(creases, window, cx)); + }; + }); + }); } }