Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
terminal_view: Show "Add to Agent Thread" on first right-click (#50860)
João Soares3b98fca3383e
diff --git a/crates/terminal_view/src/terminal_view.rs b/crates/terminal_view/src/terminal_view.rsindex 271f95bea2d..aba0040f482 100644--- a/crates/terminal_view/src/terminal_view.rs+++ b/crates/terminal_view/src/terminal_view.rs@@ -489,6 +489,7 @@ impl TerminalView {pub fn deploy_context_menu(&mut self,position: Point<Pixels>,+ has_selection: bool,window: &mut Window,cx: &mut Context<Self>,) {@@ -497,13 +498,6 @@ impl TerminalView {.upgrade().and_then(|workspace| workspace.read(cx).panel::<TerminalPanel>(cx)).is_some_and(|terminal_panel| terminal_panel.read(cx).assistant_enabled());- let has_selection = self- .terminal- .read(cx)- .last_content- .selection_text- .as_ref()- .is_some_and(|text| !text.is_empty());let context_menu = ContextMenu::build(window, cx, |menu, _, _| {menu.context(self.focus_handle.clone()).action("New Terminal", Box::new(NewTerminal::default()))@@ -1249,12 +1243,21 @@ impl Render for TerminalView {MouseButton::Right,cx.listener(|this, event: &MouseDownEvent, window, cx| {if !this.terminal.read(cx).mouse_mode(event.modifiers.shift) {- if this.terminal.read(cx).last_content.selection.is_none() {+ let had_selection = this.terminal.read(cx).last_content.selection.is_some();+ if !had_selection {this.terminal.update(cx, |terminal, _| {terminal.select_word_at_event_position(event);});- };- this.deploy_context_menu(event.position, window, cx);+ }+ let has_selection = !had_selection+ || this+ .terminal+ .read(cx)+ .last_content+ .selection_text+ .as_ref()+ .is_some_and(|text| !text.is_empty());+ this.deploy_context_menu(event.position, has_selection, window, cx);cx.notify();}}),