Add a run menu (#32505)

As part of this I refactored the logic that enabled/disabled actions in
the debugger to happen at action registration time instead of using
command palette filters. This allows the menu to grey out actions correctly.

Release Notes:

- Add a "Run" menu to contain tasks and debugger
This commit is contained in:
Conrad Irwin 2025-06-10 19:57:46 -06:00 committed by GitHub
parent 444f797827
commit 00a8101016
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 296 additions and 369 deletions

View file

@ -922,7 +922,7 @@ type PromptForOpenPath = Box<
/// that can be used to register a global action to be triggered from any place in the window.
pub struct Workspace {
weak_self: WeakEntity<Self>,
workspace_actions: Vec<Box<dyn Fn(Div, &mut Window, &mut Context<Self>) -> Div>>,
workspace_actions: Vec<Box<dyn Fn(Div, &Workspace, &mut Window, &mut Context<Self>) -> Div>>,
zoomed: Option<AnyWeakView>,
previous_dock_drag_coordinates: Option<Point<Pixels>>,
zoomed_position: Option<DockPosition>,
@ -5436,7 +5436,7 @@ impl Workspace {
) -> &mut Self {
let callback = Arc::new(callback);
self.workspace_actions.push(Box::new(move |div, _, cx| {
self.workspace_actions.push(Box::new(move |div, _, _, cx| {
let callback = callback.clone();
div.on_action(cx.listener(move |workspace, event, window, cx| {
(callback)(workspace, event, window, cx)
@ -5444,6 +5444,13 @@ impl Workspace {
}));
self
}
pub fn register_action_renderer(
&mut self,
callback: impl Fn(Div, &Workspace, &mut Window, &mut Context<Self>) -> Div + 'static,
) -> &mut Self {
self.workspace_actions.push(Box::new(callback));
self
}
fn add_workspace_actions_listeners(
&self,
@ -5452,7 +5459,7 @@ impl Workspace {
cx: &mut Context<Self>,
) -> Div {
for action in self.workspace_actions.iter() {
div = (action)(div, window, cx)
div = (action)(div, self, window, cx)
}
div
}