From 05e0a812c4034f8b5c23862e6181b6063b94da04 Mon Sep 17 00:00:00 2001 From: Julia Ryan Date: Wed, 9 Jul 2025 12:09:34 -0700 Subject: [PATCH 1/4] Add gutter runnable edit buttons --- crates/editor/src/code_context_menus.rs | 23 +++++++++++++++++++++++ crates/editor/src/element.rs | 1 - 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/crates/editor/src/code_context_menus.rs b/crates/editor/src/code_context_menus.rs index 8fbae8d605..e7403edf8a 100644 --- a/crates/editor/src/code_context_menus.rs +++ b/crates/editor/src/code_context_menus.rs @@ -1438,6 +1438,29 @@ impl CodeActionsMenu { .overflow_hidden() .child("debug: ") .child(scenario.label.clone()) + .child( + IconButton::new( + SharedString::new(format!("edit-{ix}")), + IconName::Pencil, + ) + .on_click(cx.listener( + move |editor, _, window, cx| { + cx.stop_propagation(); + if let Some(workspace) = editor.workspace() + { + workspace.update(cx, |this, cx| { + // if let Some(panel) = this.panel::(cx) { + // let kind = todo!(); + // let id = todo!(); + // panel.update_in(cx, |panel, window, cx| { + // panel.go_to_scenario_definition(kind, scenario, id, window, cx) + // })? + // } + }) + } + }, + )), + ) .when(selected, |this| { this.text_color(colors.text_accent) }), diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 014583912f..3076c00d16 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -2836,7 +2836,6 @@ impl EditorElement { ) -> Vec { self.editor.update(cx, |editor, cx| { let active_task_indicator_row = - // TODO: add edit button on the right side of each row in the context menu if let Some(crate::CodeContextMenu::CodeActions(CodeActionsMenu { deployed_from, actions, From b24a30916ae4c0126d0fbe5bdea2f6e28bf02eeb Mon Sep 17 00:00:00 2001 From: Julia Ryan Date: Fri, 11 Jul 2025 09:00:24 -0700 Subject: [PATCH 2/4] wip: start adding action --- crates/editor/src/code_context_menus.rs | 28 ++++++++++++++----------- crates/zed_actions/src/lib.rs | 25 ++++++++++++++++++++++ 2 files changed, 41 insertions(+), 12 deletions(-) diff --git a/crates/editor/src/code_context_menus.rs b/crates/editor/src/code_context_menus.rs index e7403edf8a..f7bd7beb94 100644 --- a/crates/editor/src/code_context_menus.rs +++ b/crates/editor/src/code_context_menus.rs @@ -1446,18 +1446,22 @@ impl CodeActionsMenu { .on_click(cx.listener( move |editor, _, window, cx| { cx.stop_propagation(); - if let Some(workspace) = editor.workspace() - { - workspace.update(cx, |this, cx| { - // if let Some(panel) = this.panel::(cx) { - // let kind = todo!(); - // let id = todo!(); - // panel.update_in(cx, |panel, window, cx| { - // panel.go_to_scenario_definition(kind, scenario, id, window, cx) - // })? - // } - }) - } + window.dispatch_action( + zed_actions::OpenInDebugJson.boxed_clone(), + cx, + ); + // if let Some(workspace) = editor.workspace() + // { + // workspace.update(cx, |this, cx| { + // // if let Some(panel) = this.panel::(cx) { + // // let kind = todo!(); + // // let id = todo!(); + // // panel.update_in(cx, |panel, window, cx| { + // // panel.go_to_scenario_definition(kind, scenario, id, window, cx) + // // })? + // // } + // }) + // } }, )), ) diff --git a/crates/zed_actions/src/lib.rs b/crates/zed_actions/src/lib.rs index 06121a9de8..760f00e36a 100644 --- a/crates/zed_actions/src/lib.rs +++ b/crates/zed_actions/src/lib.rs @@ -471,3 +471,28 @@ actions!( OpenProjectDebugTasks, ] ); + +/// Reruns the last task. +#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)] +#[action(namespace = debugger)] +#[serde(deny_unknown_fields)] +pub struct OpenInDebugJson { + /// Controls whether the task context is reevaluated prior to execution of a task. + /// If it is not, environment variables such as ZED_COLUMN, ZED_FILE are gonna be the same as in the last execution of a task + /// If it is, these variables will be updated to reflect current state of editor at the time task::Rerun is executed. + /// default: false + #[serde(default)] + pub reevaluate_context: bool, + /// Overrides `allow_concurrent_runs` property of the task being reran. + /// Default: null + #[serde(default)] + pub allow_concurrent_runs: Option, + /// Overrides `use_new_terminal` property of the task being reran. + /// Default: null + #[serde(default)] + pub scenario: Scenario, + + /// If present, rerun the task with this ID, otherwise rerun the last task. + #[serde(skip)] + pub task_id: Option, +} From 124b4645c4802b1bd990e6f5977f74aebb58d95b Mon Sep 17 00:00:00 2001 From: Julia Ryan Date: Fri, 18 Jul 2025 14:34:05 -0700 Subject: [PATCH 3/4] switch from action to event --- crates/editor/src/code_context_menus.rs | 34 ++++++++++--------------- crates/editor/src/items.rs | 1 + crates/zed_actions/src/lib.rs | 25 ------------------ 3 files changed, 15 insertions(+), 45 deletions(-) diff --git a/crates/editor/src/code_context_menus.rs b/crates/editor/src/code_context_menus.rs index f7bd7beb94..7c5cfaf452 100644 --- a/crates/editor/src/code_context_menus.rs +++ b/crates/editor/src/code_context_menus.rs @@ -1392,6 +1392,7 @@ impl CodeActionsMenu { ) -> AnyElement { let actions = self.actions.clone(); let selected_item = self.selected_item; + let list = uniform_list( "code_actions_menu", self.actions.len(), @@ -1443,27 +1444,15 @@ impl CodeActionsMenu { SharedString::new(format!("edit-{ix}")), IconName::Pencil, ) - .on_click(cx.listener( - move |editor, _, window, cx| { + .on_click(cx.listener({ + let scenario = scenario.clone(); + move |_, _, _window, cx| { cx.stop_propagation(); - window.dispatch_action( - zed_actions::OpenInDebugJson.boxed_clone(), - cx, - ); - // if let Some(workspace) = editor.workspace() - // { - // workspace.update(cx, |this, cx| { - // // if let Some(panel) = this.panel::(cx) { - // // let kind = todo!(); - // // let id = todo!(); - // // panel.update_in(cx, |panel, window, cx| { - // // panel.go_to_scenario_definition(kind, scenario, id, window, cx) - // // })? - // // } - // }) - // } - }, - )), + cx.emit(OpenInDebugJson { + scenario: scenario.clone(), + }); + } + })), ) .when(selected, |this| { this.text_color(colors.text_accent) @@ -1510,3 +1499,8 @@ impl CodeActionsMenu { Popover::new().child(list).into_any_element() } } + +#[derive(Clone)] +pub struct OpenInDebugJson { + pub scenario: DebugScenario, +} diff --git a/crates/editor/src/items.rs b/crates/editor/src/items.rs index 2e4631a62b..4d6b78740f 100644 --- a/crates/editor/src/items.rs +++ b/crates/editor/src/items.rs @@ -1385,6 +1385,7 @@ fn clip_ranges<'a>( } impl EventEmitter for Editor {} +impl EventEmitter for Editor {} impl Editor { pub fn update_restoration_data( diff --git a/crates/zed_actions/src/lib.rs b/crates/zed_actions/src/lib.rs index 760f00e36a..06121a9de8 100644 --- a/crates/zed_actions/src/lib.rs +++ b/crates/zed_actions/src/lib.rs @@ -471,28 +471,3 @@ actions!( OpenProjectDebugTasks, ] ); - -/// Reruns the last task. -#[derive(PartialEq, Clone, Deserialize, Default, JsonSchema, Action)] -#[action(namespace = debugger)] -#[serde(deny_unknown_fields)] -pub struct OpenInDebugJson { - /// Controls whether the task context is reevaluated prior to execution of a task. - /// If it is not, environment variables such as ZED_COLUMN, ZED_FILE are gonna be the same as in the last execution of a task - /// If it is, these variables will be updated to reflect current state of editor at the time task::Rerun is executed. - /// default: false - #[serde(default)] - pub reevaluate_context: bool, - /// Overrides `allow_concurrent_runs` property of the task being reran. - /// Default: null - #[serde(default)] - pub allow_concurrent_runs: Option, - /// Overrides `use_new_terminal` property of the task being reran. - /// Default: null - #[serde(default)] - pub scenario: Scenario, - - /// If present, rerun the task with this ID, otherwise rerun the last task. - #[serde(skip)] - pub task_id: Option, -} From bded0e12f4f60a4cb856b9e495f8ac5f33e3832f Mon Sep 17 00:00:00 2001 From: Julia Ryan Date: Tue, 22 Jul 2025 14:08:11 -0700 Subject: [PATCH 4/4] wip --- crates/debugger_ui/src/debugger_panel.rs | 21 +++++++++++++++++++- crates/debugger_ui/src/new_process_modal.rs | 8 -------- crates/editor/src/code_context_menus.rs | 22 ++++++++++++--------- crates/editor/src/items.rs | 1 - crates/workspace/src/workspace.rs | 8 ++++++++ 5 files changed, 41 insertions(+), 19 deletions(-) diff --git a/crates/debugger_ui/src/debugger_panel.rs b/crates/debugger_ui/src/debugger_panel.rs index c90a2878e9..0c74bb47bc 100644 --- a/crates/debugger_ui/src/debugger_panel.rs +++ b/crates/debugger_ui/src/debugger_panel.rs @@ -36,12 +36,12 @@ use task::{DebugScenario, TaskContext}; use tree_sitter::{Query, StreamingIterator as _}; use ui::{ContextMenu, Divider, PopoverMenuHandle, Tooltip, prelude::*}; use util::{ResultExt, maybe}; -use workspace::SplitDirection; use workspace::item::SaveOptions; use workspace::{ Item, Pane, Workspace, dock::{DockPosition, Panel, PanelEvent}, }; +use workspace::{OpenInDebugJson, SplitDirection}; use zed_actions::ToggleFocus; pub enum DebugPanelEvent { @@ -98,6 +98,25 @@ impl DebugPanel { }, ); + if let Some(entity) = workspace.weak_handle().upgrade() { + let edit_scenario_subscription = cx.subscribe_in( + &entity, + window, + move |this, workspace, OpenInDebugJson { scenario, id }, window, cx| { + let task = this.go_to_scenario_definition( + TaskSourceKind::UserInput, + scenario.clone(), + todo!(), + // *id, + window, + cx, + ); + cx.spawn(async move |_, cx| task.await) + .detach_and_log_err(cx); + }, + ); + } + Self { size: px(300.), sessions: vec![], diff --git a/crates/debugger_ui/src/new_process_modal.rs b/crates/debugger_ui/src/new_process_modal.rs index 6d7fa244a2..0aeb91f938 100644 --- a/crates/debugger_ui/src/new_process_modal.rs +++ b/crates/debugger_ui/src/new_process_modal.rs @@ -343,12 +343,6 @@ impl NewProcessModal { return; } - if let NewProcessMode::Launch = &self.mode { - if self.configure_mode.read(cx).save_to_debug_json.selected() { - self.save_debug_scenario(window, cx); - } - } - let Some(debugger) = self.debugger.clone() else { return; }; @@ -806,7 +800,6 @@ pub(super) struct ConfigureMode { program: Entity, cwd: Entity, stop_on_entry: ToggleState, - save_to_debug_json: ToggleState, } impl ConfigureMode { @@ -825,7 +818,6 @@ impl ConfigureMode { program, cwd, stop_on_entry: ToggleState::Unselected, - save_to_debug_json: ToggleState::Unselected, }) } diff --git a/crates/editor/src/code_context_menus.rs b/crates/editor/src/code_context_menus.rs index 7c5cfaf452..9ec976563d 100644 --- a/crates/editor/src/code_context_menus.rs +++ b/crates/editor/src/code_context_menus.rs @@ -1446,11 +1446,20 @@ impl CodeActionsMenu { ) .on_click(cx.listener({ let scenario = scenario.clone(); - move |_, _, _window, cx| { + move |editor, _, _window, cx| { + if let Some((workspace, Some(id))) = + editor.workspace.as_ref() + { + workspace + .update(cx, |_, cx| { + cx.emit(workspace::OpenInDebugJson { + scenario: scenario.clone(), + id: *id, + }); + }) + .ok(); + } cx.stop_propagation(); - cx.emit(OpenInDebugJson { - scenario: scenario.clone(), - }); } })), ) @@ -1499,8 +1508,3 @@ impl CodeActionsMenu { Popover::new().child(list).into_any_element() } } - -#[derive(Clone)] -pub struct OpenInDebugJson { - pub scenario: DebugScenario, -} diff --git a/crates/editor/src/items.rs b/crates/editor/src/items.rs index 4d6b78740f..2e4631a62b 100644 --- a/crates/editor/src/items.rs +++ b/crates/editor/src/items.rs @@ -1385,7 +1385,6 @@ fn clip_ranges<'a>( } impl EventEmitter for Editor {} -impl EventEmitter for Editor {} impl Editor { pub fn update_restoration_data( diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 125b5bb98a..2371f2f7c6 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -1092,6 +1092,14 @@ pub struct Workspace { impl EventEmitter for Workspace {} +#[derive(Clone)] +pub struct OpenInDebugJson { + pub scenario: DebugScenario, + pub id: WorkspaceId, +} + +impl EventEmitter for Workspace {} + #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] pub struct ViewId { pub creator: CollaboratorId,