debugger: Add actions and keybindings for opening the thread and session menus (#31135)
Makes it possible to open and navigate these menus from the keyboard. I also removed the eager previewing behavior for the thread picker, which was buggy and came with a jarring layout shift. Release Notes: - Debugger Beta: Added the `debugger: open thread picker` and `debugger: open session picker` actions.
This commit is contained in:
parent
eb35d25a7d
commit
b2a92097ee
8 changed files with 76 additions and 68 deletions
|
@ -154,7 +154,6 @@ pub struct ContextMenu {
|
|||
key_context: SharedString,
|
||||
_on_blur_subscription: Subscription,
|
||||
keep_open_on_confirm: bool,
|
||||
eager: bool,
|
||||
documentation_aside: Option<(usize, DocumentationAside)>,
|
||||
fixed_width: Option<DefiniteLength>,
|
||||
}
|
||||
|
@ -207,7 +206,6 @@ impl ContextMenu {
|
|||
key_context: "menu".into(),
|
||||
_on_blur_subscription,
|
||||
keep_open_on_confirm: false,
|
||||
eager: false,
|
||||
documentation_aside: None,
|
||||
fixed_width: None,
|
||||
end_slot_action: None,
|
||||
|
@ -250,43 +248,6 @@ impl ContextMenu {
|
|||
key_context: "menu".into(),
|
||||
_on_blur_subscription,
|
||||
keep_open_on_confirm: true,
|
||||
eager: false,
|
||||
documentation_aside: None,
|
||||
fixed_width: None,
|
||||
end_slot_action: None,
|
||||
},
|
||||
window,
|
||||
cx,
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
pub fn build_eager(
|
||||
window: &mut Window,
|
||||
cx: &mut App,
|
||||
f: impl FnOnce(Self, &mut Window, &mut Context<Self>) -> Self,
|
||||
) -> Entity<Self> {
|
||||
cx.new(|cx| {
|
||||
let focus_handle = cx.focus_handle();
|
||||
let _on_blur_subscription = cx.on_blur(
|
||||
&focus_handle,
|
||||
window,
|
||||
|this: &mut ContextMenu, window, cx| this.cancel(&menu::Cancel, window, cx),
|
||||
);
|
||||
window.refresh();
|
||||
f(
|
||||
Self {
|
||||
builder: None,
|
||||
items: Default::default(),
|
||||
focus_handle,
|
||||
action_context: None,
|
||||
selected_index: None,
|
||||
delayed: false,
|
||||
clicked: false,
|
||||
key_context: "menu".into(),
|
||||
_on_blur_subscription,
|
||||
keep_open_on_confirm: false,
|
||||
eager: true,
|
||||
documentation_aside: None,
|
||||
fixed_width: None,
|
||||
end_slot_action: None,
|
||||
|
@ -327,7 +288,6 @@ impl ContextMenu {
|
|||
|this: &mut ContextMenu, window, cx| this.cancel(&menu::Cancel, window, cx),
|
||||
),
|
||||
keep_open_on_confirm: false,
|
||||
eager: false,
|
||||
documentation_aside: None,
|
||||
fixed_width: None,
|
||||
end_slot_action: None,
|
||||
|
@ -634,10 +594,7 @@ impl ContextMenu {
|
|||
..
|
||||
})
|
||||
| ContextMenuItem::CustomEntry { handler, .. },
|
||||
) = self
|
||||
.selected_index
|
||||
.and_then(|ix| self.items.get(ix))
|
||||
.filter(|_| !self.eager)
|
||||
) = self.selected_index.and_then(|ix| self.items.get(ix))
|
||||
{
|
||||
(handler)(context, window, cx)
|
||||
}
|
||||
|
@ -740,10 +697,9 @@ impl ContextMenu {
|
|||
fn select_index(
|
||||
&mut self,
|
||||
ix: usize,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
_window: &mut Window,
|
||||
_cx: &mut Context<Self>,
|
||||
) -> Option<usize> {
|
||||
let context = self.action_context.as_ref();
|
||||
self.documentation_aside = None;
|
||||
let item = self.items.get(ix)?;
|
||||
if item.is_selectable() {
|
||||
|
@ -752,9 +708,6 @@ impl ContextMenu {
|
|||
if let Some(callback) = &entry.documentation_aside {
|
||||
self.documentation_aside = Some((ix, callback.clone()));
|
||||
}
|
||||
if self.eager && !entry.disabled {
|
||||
(entry.handler)(context, window, cx)
|
||||
}
|
||||
}
|
||||
}
|
||||
Some(ix)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue