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)).
This commit is contained in:
parent
fc9f84446a
commit
6286d86262
3 changed files with 12 additions and 6 deletions
|
@ -5,9 +5,9 @@ use collections::{HashMap, HashSet};
|
||||||
use db::kvp::KEY_VALUE_STORE;
|
use db::kvp::KEY_VALUE_STORE;
|
||||||
use futures::future::join_all;
|
use futures::future::join_all;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions, AppContext, AsyncWindowContext, Entity, EventEmitter, ExternalPaths, FocusHandle,
|
actions, Action, AppContext, AsyncWindowContext, Entity, EventEmitter, ExternalPaths,
|
||||||
FocusableView, IntoElement, ParentElement, Pixels, Render, Styled, Subscription, Task, View,
|
FocusHandle, FocusableView, IntoElement, ParentElement, Pixels, Render, Styled, Subscription,
|
||||||
ViewContext, VisualContext, WeakView, WindowContext,
|
Task, View, ViewContext, VisualContext, WeakView, WindowContext,
|
||||||
};
|
};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use project::{Fs, ProjectEntryId};
|
use project::{Fs, ProjectEntryId};
|
||||||
|
@ -26,7 +26,7 @@ use workspace::{
|
||||||
item::Item,
|
item::Item,
|
||||||
pane,
|
pane,
|
||||||
ui::IconName,
|
ui::IconName,
|
||||||
DraggedTab, Pane, Workspace,
|
DraggedTab, NewTerminal, Pane, Workspace,
|
||||||
};
|
};
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
@ -69,6 +69,7 @@ impl TerminalPanel {
|
||||||
workspace.project().clone(),
|
workspace.project().clone(),
|
||||||
Default::default(),
|
Default::default(),
|
||||||
None,
|
None,
|
||||||
|
NewTerminal.boxed_clone(),
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
pane.set_can_split(false, cx);
|
pane.set_can_split(false, cx);
|
||||||
|
|
|
@ -183,6 +183,7 @@ pub struct Pane {
|
||||||
_subscriptions: Vec<Subscription>,
|
_subscriptions: Vec<Subscription>,
|
||||||
tab_bar_scroll_handle: ScrollHandle,
|
tab_bar_scroll_handle: ScrollHandle,
|
||||||
display_nav_history_buttons: bool,
|
display_nav_history_buttons: bool,
|
||||||
|
double_click_dispatch_action: Box<dyn Action>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ItemNavHistory {
|
pub struct ItemNavHistory {
|
||||||
|
@ -242,6 +243,7 @@ impl Pane {
|
||||||
project: Model<Project>,
|
project: Model<Project>,
|
||||||
next_timestamp: Arc<AtomicUsize>,
|
next_timestamp: Arc<AtomicUsize>,
|
||||||
can_drop_predicate: Option<Arc<dyn Fn(&dyn Any, &mut WindowContext) -> bool + 'static>>,
|
can_drop_predicate: Option<Arc<dyn Fn(&dyn Any, &mut WindowContext) -> bool + 'static>>,
|
||||||
|
double_click_dispatch_action: Box<dyn Action>,
|
||||||
cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let focus_handle = cx.focus_handle();
|
let focus_handle = cx.focus_handle();
|
||||||
|
@ -346,6 +348,7 @@ impl Pane {
|
||||||
}),
|
}),
|
||||||
display_nav_history_buttons: true,
|
display_nav_history_buttons: true,
|
||||||
_subscriptions: subscriptions,
|
_subscriptions: subscriptions,
|
||||||
|
double_click_dispatch_action,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1550,9 +1553,9 @@ impl Pane {
|
||||||
this.drag_split_direction = None;
|
this.drag_split_direction = None;
|
||||||
this.handle_external_paths_drop(paths, cx)
|
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 {
|
if event.up.click_count == 2 {
|
||||||
cx.dispatch_action(NewFile.boxed_clone());
|
cx.dispatch_action(this.double_click_dispatch_action.boxed_clone())
|
||||||
}
|
}
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
|
|
|
@ -618,6 +618,7 @@ impl Workspace {
|
||||||
project.clone(),
|
project.clone(),
|
||||||
pane_history_timestamp.clone(),
|
pane_history_timestamp.clone(),
|
||||||
None,
|
None,
|
||||||
|
NewFile.boxed_clone(),
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
@ -1860,6 +1861,7 @@ impl Workspace {
|
||||||
self.project.clone(),
|
self.project.clone(),
|
||||||
self.pane_history_timestamp.clone(),
|
self.pane_history_timestamp.clone(),
|
||||||
None,
|
None,
|
||||||
|
NewFile.boxed_clone(),
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue