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

@ -203,6 +203,30 @@ pub fn app_menus() -> Vec<Menu> {
MenuItem::action("Previous Problem", editor::actions::GoToPreviousDiagnostic),
],
},
Menu {
name: "Run".into(),
items: vec![
MenuItem::action(
"Spawn Task",
zed_actions::Spawn::ViaModal {
reveal_target: None,
},
),
MenuItem::action("Start Debugger", debugger_ui::Start),
MenuItem::separator(),
MenuItem::action("Edit tasks.json...", crate::zed::OpenProjectTasks),
MenuItem::action("Edit debug.json...", crate::zed::OpenProjectDebugTasks),
MenuItem::separator(),
MenuItem::action("Continue", debugger_ui::Continue),
MenuItem::action("Step Over", debugger_ui::StepOver),
MenuItem::action("Step Into", debugger_ui::StepInto),
MenuItem::action("Step Out", debugger_ui::StepOut),
MenuItem::separator(),
MenuItem::action("Toggle Breakpoint", editor::actions::ToggleBreakpoint),
MenuItem::action("Edit Breakpoint", editor::actions::EditLogBreakpoint),
MenuItem::action("Clear all Breakpoints", debugger_ui::ClearAllBreakpoints),
],
},
Menu {
name: "Window".into(),
items: vec![

View file

@ -133,46 +133,6 @@ impl Render for QuickActionBar {
)
});
let last_run_debug = self
.workspace
.read_with(cx, |workspace, cx| {
workspace
.debugger_provider()
.map(|provider| provider.debug_scenario_scheduled_last(cx))
.unwrap_or_default()
})
.ok()
.unwrap_or_default();
let run_button = if last_run_debug {
QuickActionBarButton::new(
"debug",
IconName::PlayBug,
false,
Box::new(debugger_ui::Start),
focus_handle.clone(),
"Debug",
move |_, window, cx| {
window.dispatch_action(Box::new(debugger_ui::Start), cx);
},
)
} else {
let action = Box::new(tasks_ui::Spawn::ViaModal {
reveal_target: None,
});
QuickActionBarButton::new(
"run",
IconName::PlayAlt,
false,
action.boxed_clone(),
focus_handle.clone(),
"Spawn Task",
move |_, window, cx| {
window.dispatch_action(action.boxed_clone(), cx);
},
)
};
let assistant_button = QuickActionBarButton::new(
"toggle inline assistant",
IconName::ZedAssistant,
@ -601,7 +561,6 @@ impl Render for QuickActionBar {
AgentSettings::get_global(cx).enabled && AgentSettings::get_global(cx).button,
|bar| bar.child(assistant_button),
)
.child(run_button)
.children(code_actions_dropdown)
.children(editor_selections_dropdown)
.child(editor_settings_dropdown)