From 6286d86262ef9fd6e79b66c0024ea502c3f3243d Mon Sep 17 00:00:00 2001 From: Igal Tabachnik Date: Wed, 13 Mar 2024 17:30:10 +0200 Subject: [PATCH] Set the correct dispatch action for the double-click handler for the pane tab bar (#9221) Fixes #9003 Release Notes: - Fixed the double-click action on the terminal tab bar opening a new buffer instead of a new terminal ([#9003](https://github.com/zed-industries/zed/issues/9003)). --- crates/terminal_view/src/terminal_panel.rs | 9 +++++---- crates/workspace/src/pane.rs | 7 +++++-- crates/workspace/src/workspace.rs | 2 ++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/crates/terminal_view/src/terminal_panel.rs b/crates/terminal_view/src/terminal_panel.rs index d4174d61c81b69fe8ea2758e51c01b4449a3aba9..07e6460fa97492e68839af0ddfdbb59fa61a83b4 100644 --- a/crates/terminal_view/src/terminal_panel.rs +++ b/crates/terminal_view/src/terminal_panel.rs @@ -5,9 +5,9 @@ use collections::{HashMap, HashSet}; use db::kvp::KEY_VALUE_STORE; use futures::future::join_all; use gpui::{ - actions, AppContext, AsyncWindowContext, Entity, EventEmitter, ExternalPaths, FocusHandle, - FocusableView, IntoElement, ParentElement, Pixels, Render, Styled, Subscription, Task, View, - ViewContext, VisualContext, WeakView, WindowContext, + actions, Action, AppContext, AsyncWindowContext, Entity, EventEmitter, ExternalPaths, + FocusHandle, FocusableView, IntoElement, ParentElement, Pixels, Render, Styled, Subscription, + Task, View, ViewContext, VisualContext, WeakView, WindowContext, }; use itertools::Itertools; use project::{Fs, ProjectEntryId}; @@ -26,7 +26,7 @@ use workspace::{ item::Item, pane, ui::IconName, - DraggedTab, Pane, Workspace, + DraggedTab, NewTerminal, Pane, Workspace, }; use anyhow::Result; @@ -69,6 +69,7 @@ impl TerminalPanel { workspace.project().clone(), Default::default(), None, + NewTerminal.boxed_clone(), cx, ); pane.set_can_split(false, cx); diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs index a7d46264ee31c43f2c77557476d2c34d9e0159ac..24eac074435e2e0c7900288061225846d9fe972c 100644 --- a/crates/workspace/src/pane.rs +++ b/crates/workspace/src/pane.rs @@ -183,6 +183,7 @@ pub struct Pane { _subscriptions: Vec, tab_bar_scroll_handle: ScrollHandle, display_nav_history_buttons: bool, + double_click_dispatch_action: Box, } pub struct ItemNavHistory { @@ -242,6 +243,7 @@ impl Pane { project: Model, next_timestamp: Arc, can_drop_predicate: Option bool + 'static>>, + double_click_dispatch_action: Box, cx: &mut ViewContext, ) -> Self { let focus_handle = cx.focus_handle(); @@ -346,6 +348,7 @@ impl Pane { }), display_nav_history_buttons: true, _subscriptions: subscriptions, + double_click_dispatch_action, } } @@ -1550,9 +1553,9 @@ impl Pane { this.drag_split_direction = None; this.handle_external_paths_drop(paths, cx) })) - .on_click(cx.listener(move |_, event: &ClickEvent, cx| { + .on_click(cx.listener(move |this, event: &ClickEvent, cx| { if event.up.click_count == 2 { - cx.dispatch_action(NewFile.boxed_clone()); + cx.dispatch_action(this.double_click_dispatch_action.boxed_clone()) } })), ) diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 45e98e4430b38fdbda28a90352aa10b60c1aef69..01c7c5e3dd0b048d2e21c7eb34588852eab36150 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -618,6 +618,7 @@ impl Workspace { project.clone(), pane_history_timestamp.clone(), None, + NewFile.boxed_clone(), cx, ) }); @@ -1860,6 +1861,7 @@ impl Workspace { self.project.clone(), self.pane_history_timestamp.clone(), None, + NewFile.boxed_clone(), cx, ) });