Fix bug with action keybindings not being resolved

This commit is contained in:
Mikayla Maki 2023-03-08 18:11:11 -08:00
parent 152755b043
commit cf6ea6d698
6 changed files with 44 additions and 12 deletions

View file

@ -187,7 +187,14 @@ impl Dock {
) -> Self {
let position = DockPosition::Hidden(cx.global::<Settings>().default_dock_anchor);
let pane = cx.add_view(|cx| Pane::new(Some(position.anchor()), background_actions, cx));
let pane = cx.add_view(|cx| {
Pane::new(
cx.handle().id(),
Some(position.anchor()),
background_actions,
cx,
)
});
pane.update(cx, |pane, cx| {
pane.set_active(false, cx);
});

View file

@ -218,6 +218,7 @@ pub struct Pane {
tab_bar_context_menu: ViewHandle<ContextMenu>,
docked: Option<DockAnchor>,
background_actions: BackgroundActions,
workspace_id: usize,
}
pub struct ItemNavHistory {
@ -275,6 +276,7 @@ enum ItemType {
impl Pane {
pub fn new(
workspace_id: usize,
docked: Option<DockAnchor>,
background_actions: BackgroundActions,
cx: &mut ViewContext<Self>,
@ -300,6 +302,7 @@ impl Pane {
tab_bar_context_menu: context_menu,
docked,
background_actions,
workspace_id,
}
}
@ -1442,6 +1445,7 @@ impl Pane {
.with_children({
enum KeyboardHint {}
let keyboard_hint = &theme.keyboard_hint;
let workspace_id = self.workspace_id;
(self.background_actions)().into_iter().enumerate().map(
move |(idx, (text, action))| {
let hint_action = action.boxed_clone();
@ -1449,14 +1453,15 @@ impl Pane {
idx,
cx,
move |state, cx| {
theme::ui::keystroke_label(
theme::ui::keystroke_label_for(
cx.window_id(),
workspace_id,
text,
&keyboard_hint.style_for(state, false),
&keystroke_style
.style_for(state, false)
.keystroke,
hint_action,
cx,
)
.boxed()
},

View file

@ -606,7 +606,9 @@ impl Workspace {
})
.detach();
let center_pane = cx.add_view(|cx| Pane::new(None, background_actions, cx));
let workspace_view_id = cx.handle().id();
let center_pane =
cx.add_view(|cx| Pane::new(workspace_view_id, None, background_actions, cx));
let pane_id = center_pane.id();
cx.subscribe(&center_pane, move |this, _, event, cx| {
this.handle_pane_event(pane_id, event, cx)
@ -1438,7 +1440,7 @@ impl Workspace {
}
fn add_pane(&mut self, cx: &mut ViewContext<Self>) -> ViewHandle<Pane> {
let pane = cx.add_view(|cx| Pane::new(None, self.background_actions, cx));
let pane = cx.add_view(|cx| Pane::new(cx.handle().id(), None, self.background_actions, cx));
let pane_id = pane.id();
cx.subscribe(&pane, move |this, _, event, cx| {
this.handle_pane_event(pane_id, event, cx)