Visual Studio Code, rebuilt in Rust
Rust
feat(debug): keep a dynamic selection's type for F5
rokartura7c650495dac
diff --git a/native/crates/app/src/workbench/debug_commands.rs b/native/crates/app/src/workbench/debug_commands.rsindex 5af1674acba..0c39d154d48 100644--- a/native/crates/app/src/workbench/debug_commands.rs+++ b/native/crates/app/src/workbench/debug_commands.rs@@ -24,6 +24,10 @@ impl Workbench {self.register_variable_menu_commands();let start = |no_debug: bool| {move |workbench: &mut Workbench, _: Vec<Value>, window: &mut Window, cx: &mut Context<Workbench>| {+ if let Some((folder, name, debug_type)) = workbench.selected_dynamic() {+ workbench.start_dynamic(folder, name, debug_type, json!({ "noDebug": no_debug, "startedByUser": true }), window, cx);+ return Outcome::done();+ }let (folder, name) = workbench.selected_launch();let target = name.map_or(Value::Null, Value::String);Outcome::Pending(workbench.start_debugging(folder, target, json!({ "noDebug": no_debug, "startedByUser": true }), DebugTasks::PreLaunch, window, cx))@@ -242,9 +246,12 @@ impl Workbench {});}- /// `debugService.getConfigurationManager().selectedConfiguration`: the stored choice while it exists, else the- /// first folder's first configuration.+ /// `debugService.getConfigurationManager().selectedConfiguration`: the stored choice while it exists or is a+ /// dynamic one, else the first folder's first configuration.pub(crate) fn selected_launch(&self) -> (Option<PathBuf>, Option<String>) {+ if let Some((folder, name, _)) = self.selected_dynamic() {+ return (folder, Some(name));+ }let folders = self.workspace_folders();if let Some((root, name)) = &self.debug.selected {let folder = root.clone().or_else(|| folders.first().cloned());@@ -363,6 +370,9 @@ impl Workbench {match self.debug.state() {State::Inactive => {self.debug_view.run_to_cursor = breakpoint;+ if let Some((folder, name, debug_type)) = self.selected_dynamic() {+ return self.start_dynamic(folder, name, debug_type, json!({}), window, cx);+ }let (folder, name) = self.selected_launch();drop(self.start_debugging(folder, name.map_or(Value::Null, Value::String), json!({}), DebugTasks::PreLaunch, window, cx));}diff --git a/native/crates/app/src/workbench/debug_dynamic.rs b/native/crates/app/src/workbench/debug_dynamic.rsindex 5b43373c966..f5005760bc7 100644--- a/native/crates/app/src/workbench/debug_dynamic.rs+++ b/native/crates/app/src/workbench/debug_dynamic.rs@@ -103,14 +103,15 @@ impl Workbench {self.store_recent_dynamic_configurations(&recent);}- /// `selectConfiguration(launch, name, config, { type })`: the name selected and put first in the recent list.- // shortcut: the selection keeps the name but not the type, so the Run and Debug dropdown and F5 fall back to launch.json's first configuration; upgrade with debugConfigurationManager.ts `selectedType`.+ /// `selectConfiguration(launch, name, config, { type })`: the name selected under the provider's type and put+ /// first in the recent list.fn select_dynamic_configuration(&mut self, folder: Option<PathBuf>, name: String, debug_type: String) {let mut recent = self.recent_dynamic_configurations();recent.retain(|(known_name, known_type)| *known_name != name || *known_type != debug_type);- recent.insert(0, (name.clone(), debug_type));+ recent.insert(0, (name.clone(), debug_type.clone()));self.store_recent_dynamic_configurations(&recent);self.debug.selected = Some((folder, name));+ self.debug.selected_type = Some(debug_type);self.store_selected_configuration();}@@ -134,6 +135,22 @@ impl Workbench {pub(super) fn start_recent_dynamic(&mut self, name: String, debug_type: String, window: &mut Window, cx: &mut Context<Self>) {let (folder, _) = self.selected_launch();self.select_dynamic_configuration(folder.clone(), name.clone(), debug_type.clone());+ self.start_dynamic(folder, name, debug_type, json!({ "startedByUser": true }), window, cx);+ }++ /// The selected launch's dynamic selection, when launch.json has no configuration of its name+ /// (debugConfigurationManager.ts `selectConfiguration` asks the type's providers then).+ pub(super) fn selected_dynamic(&self) -> Option<(Option<PathBuf>, String, String)> {+ let (root, name) = self.debug.selected.clone()?;+ let debug_type = self.debug.selected_type.clone()?;+ let folder = root.or_else(|| self.workspace_folders().first().cloned());+ let in_launch_json = folder.as_ref().is_some_and(|folder| self.folder_launch(folder).configuration_names().contains(&name));+ (!in_launch_json).then_some((folder, name, debug_type))+ }++ /// `selectedConfiguration.getConfig()` of a dynamic selection: the type's provider's configuration of that name+ /// for the folder, started with `options`.+ pub(super) fn start_dynamic(&mut self, folder: Option<PathBuf>, name: String, debug_type: String, options: Value, window: &mut Window, cx: &mut Context<Self>) {let launches: Vec<Launch> = folder.clone().map(Launch::Folder).into_iter().collect();cx.spawn_in(window, async move |this, cx| {let configurations = match provide_dynamic_configurations(&this, cx, &debug_type, launches).await {@@ -141,7 +158,7 @@ impl Workbench {Err(message) => return drop(on_workbench(&this, cx, |workbench, _, _| workbench.notify_error(message))),};let config = configurations.into_iter().map(|(_, config)| config).find(|config| config["name"].as_str() == Some(&name));- let _ = on_workbench(&this, cx, |workbench, window, cx| drop(workbench.start_debugging(folder, config.unwrap_or(Value::Null), json!({ "startedByUser": true }), DebugTasks::PreLaunch, window, cx)));+ let _ = on_workbench(&this, cx, |workbench, window, cx| drop(workbench.start_debugging(folder, config.unwrap_or(Value::Null), options, DebugTasks::PreLaunch, window, cx)));}).detach();}@@ -237,6 +254,7 @@ impl Workbench {return self.notify_error(error);}self.debug.selected = Some((folder, name.clone()));+ self.debug.selected_type = None;self.store_selected_configuration();self.remove_recent_dynamic_configuration(&name, debug_type);}diff --git a/native/crates/app/src/workbench/debug_service.rs b/native/crates/app/src/workbench/debug_service.rsindex 951c2a1bfd0..deb05b1c877 100644--- a/native/crates/app/src/workbench/debug_service.rs+++ b/native/crates/app/src/workbench/debug_service.rs@@ -35,6 +35,7 @@ enum Debuggee {const CHOSEN_ENVIRONMENTS_KEY: &str = "debug.chosenenvironment";const SELECTED_CONFIG_KEY: &str = "debug.selectedconfigname";const SELECTED_ROOT_KEY: &str = "debug.selectedroot";+const SELECTED_TYPE_KEY: &str = "debug.selectedtype";/// `debug_pick`'s answer for an item's button: this prefix, then the item's handle.pub(super) const BUTTON_ANSWER: &str = "button:";@@ -101,6 +102,8 @@ pub struct DebugService {used_debug_types: HashSet<String>,/// The launch configuration the Run and Debug view's dropdown selects: its folder and name.pub selected: Option<(Option<PathBuf>, String)>,+ /// debugConfigurationManager.ts `selectedType` of a dynamic selection: its provider's type.+ pub selected_type: Option<String>,/// breakpointsView.ts `hintContainer`: the unverified breakpoints message the Breakpoints header shows.pub breakpoints_hint: Option<String>,/// breakpointsView.ts `hintDelayer`, pending.@@ -412,6 +415,7 @@ impl Workbench {self.debug.chosen_environments = storage.get(CHOSEN_ENVIRONMENTS_KEY).and_then(|raw| serde_json::from_str(raw).ok()).unwrap_or_default();let name = storage.get(SELECTED_CONFIG_KEY).map(str::to_owned);let root = storage.get(SELECTED_ROOT_KEY).and_then(crate::editor_history::file_path);+ self.debug.selected_type = storage.get(SELECTED_TYPE_KEY).map(str::to_owned);drop(storage);self.debug.selected = name.map(|name| (root, name));let ids = self.debug.model.all_ids();@@ -436,6 +440,10 @@ impl Workbench {storage.delete(SELECTED_ROOT_KEY);}}+ match &self.debug.selected_type {+ Some(debug_type) => storage.set(SELECTED_TYPE_KEY, debug_type.clone()),+ None => storage.delete(SELECTED_TYPE_KEY),+ }drop(storage);self.update_debug_status();}diff --git a/native/crates/app/src/workbench/quick_access/start_debug.rs b/native/crates/app/src/workbench/quick_access/start_debug.rsindex cc03b4246d4..c94aed31212 100644--- a/native/crates/app/src/workbench/quick_access/start_debug.rs+++ b/native/crates/app/src/workbench/quick_access/start_debug.rs@@ -132,6 +132,7 @@ impl Workbench {match pick {DebugPick::Launch { folder, name } => {self.debug.selected = Some((Some(folder.clone()), name.clone()));+ self.debug.selected_type = None;self.store_selected_configuration();drop(self.start_debugging(Some(folder), json!(name), json!({ "startedByUser": true }), DebugTasks::PreLaunch, window, cx));}diff --git a/native/crates/app/src/workbench/quick_access/tests.rs b/native/crates/app/src/workbench/quick_access/tests.rsindex 80eefd5dfdf..69f1652c3b4 100644--- a/native/crates/app/src/workbench/quick_access/tests.rs+++ b/native/crates/app/src/workbench/quick_access/tests.rs@@ -335,6 +335,65 @@ fn the_debug_picker_lists_and_starts_the_launch_configurations(cx: &mut TestAppCstd::fs::remove_dir_all(dir).unwrap();}+/// debugConfigurationManager.ts `selectConfiguration(launch, name, undefined, { type })`: a picked dynamic+/// configuration stays selected under its type (`debug.selectedtype`), F5 asks its provider for it again, and a+/// launch.json pick drops the type.+#[gpui::test]+fn a_dynamic_selection_keeps_its_type_for_f5(cx: &mut TestAppContext) {+ let app_root = Path::new(env!("VSCODE_SRC")).to_path_buf();+ let themes = scan_extension(&app_root.join("extensions/theme-defaults"), true).unwrap();+ let theme = load_theme(&[themes], "Dark Modern").unwrap();+ let dir = std::env::temp_dir().join(format!("code-gpui-debug-dynamic-{}", std::process::id()));+ let folder = dir.join("folder");+ std::fs::create_dir_all(folder.join(".vscode")).unwrap();+ std::fs::create_dir_all(dir.join("User")).unwrap();+ std::fs::write(folder.join(".vscode/launch.json"), json!({ "configurations": [{ "name": "Launch app.js", "type": "node", "request": "launch" }] }).to_string()).unwrap();+ let workspace = config::workspace::Workspace::folder(folder.clone());+ let settings = Arc::new(Mutex::new(config::service::Settings::load(config::registry::Registry::with_extensions(&[]), dir.join("User"), Some(workspace.clone()))));+ let (sender, host) = std::sync::mpsc::channel();+ let (workbench, cx) = cx.add_window_view(|_, cx| {+ let mut workbench = Workbench::new(theme, app_root.clone(), Some(workspace), Languages::new(&[]), settings, HostSync::new(sender), cx);+ let provider = crate::workbench::debug_service::ConfigurationProvider { handle: 1, debug_type: "node".into(), trigger_kind: 2, has_provide: true, has_resolve: false, has_resolve2: false };+ workbench.debug.providers.push(provider);+ workbench+ });+ cx.run_until_parked();+ let provided = |cx: &mut gpui::VisualTestContext| {+ let mut provided = 0;+ loop {+ cx.run_until_parked();+ let messages: Vec<_> = host.try_iter().collect();+ if messages.is_empty() {+ return provided;+ }+ for message in messages {+ let answer = match message.method {+ "$provideDebugConfigurations" => {+ provided += 1;+ json!([{ "name": "Run Script: test", "type": "node-terminal", "request": "launch" }])+ }+ _ => serde_json::Value::Null,+ };+ if let Some(reply) = message.reply {+ let _ = reply.send(Ok(answer));+ }+ }+ }+ };+ let selection = |cx: &mut gpui::VisualTestContext| workbench.read_with(cx, |workbench, _| (workbench.selected_launch().1, workbench.workspace_storage.lock().unwrap().get("debug.selectedtype").map(str::to_owned)));++ workbench.update_in(cx, |workbench, window, cx| workbench.start_recent_dynamic("Run Script: test".into(), "node".into(), window, cx));+ assert_eq!(provided(cx), 1);+ assert_eq!(selection(cx), (Some("Run Script: test".into()), Some("node".into())));+ workbench.update_in(cx, |workbench, window, cx| drop(workbench.execute_command("workbench.action.debug.start", Vec::new(), window, cx)));+ assert_eq!(provided(cx), 1, "F5 starts the dynamic selection");++ workbench.update_in(cx, |workbench, window, cx| workbench.accept_debug_pick(super::start_debug::DebugPick::Launch { folder: folder.clone(), name: "Launch app.js".into() }, window, cx));+ provided(cx);+ assert_eq!(selection(cx), (Some("Launch app.js".into()), None));+ std::fs::remove_dir_all(dir).unwrap();+}+#[test]fn removing_a_recently_used_pick_keeps_the_others() {let mut input = crate::quick_input::QuickInput::new(1, crate::quick_input::Kind::QuickPick);diff --git a/port/ledger.md b/port/ledger.mdindex a161f93f21e..077ebcf741e 100644--- a/port/ledger.md+++ b/port/ledger.md@@ -530,7 +530,7 @@ One row per upstream unit, generated by `bun port/tools/gen-ledger.ts`; mileston| workbench/contrib/commands | workbench contribution | M9 | verified | | runCommands (commands.rs register_run_commands): cargo test -p app commands::, argument checks, spread args, order, stop at a failure; argument errors and the failure notify (cargo test -p app run_commands_argument_errors_notify) || workbench/contrib/comments | workbench contribution | M13 | verified | | workbench/comments_view.rs, workbench/comment_thread_widget.rs, comment_thread_floating.rs, workbench/comment_thread_floating_layout.rs, workbench/comment_node.rs, workbench/commenting_ranges.rs, workbench/comment_navigation.rs, workbench/editor_view/comment_glyph.rs, multi_diff_editor_view.rs: cargo test -p app comment diff floating room multi_diff comment_thread_floating two_threads_keep_their_reply_forms_open_together a_wrapped_comment_body_grows_its_zone the_reached_thread_takes_the_focus a_markdown_comment_previews_its_first_rendered_block the_filter_keeps_its_history_and_escape_clears_it the_thread_menu_replies_to_the_thread a_comment_s_code_span_draws_no_code_block_background additional_actions_show_under_the_body_and_run_with_the_thread a_commenting_range_is_reached_at_its_columns_unless_it_holds_the_cursor dismissing_a_new_template_keeps_it_open an_expanded_thread_shows_a_zone_and_replies_run_the_form_actions a_comment_switched_to_editing_runs_the_edit_actions rows_sit_in_the_pane_s_inset_with_the_tree_s_indent_and_guides (commentThreadFloatingWidget.test.ts); ui-pair `portComments.openDiff` (modified, original, multi, floating), steps-comment-floating.json, steps-comment-additional.json, steps-comment-escape-typed.json, steps-comment-reply-editor.json, steps-comments.json (port/results/language-features.md Comments, Comment editing and commands, Floating comment threads); cargo test -p app reactions_are_action_items_4px_apart || workbench/contrib/customEditor | workbench contribution | M17 | ported | [3 L] custom_editors.rs: a diff always opens in the text diff editor, where customEditors.ts `createDiffEditorInput` opens a diff of resources matching an editor's selector (`workbench.diffEditorAssociations`, `priority.diffEditor`) as a `CustomEditorDiffInput` (customEditorDiffInput.ts, inline) or a `DiffEditorInput` of two `CustomEditorSideBySideDiffInput`s or `CustomEditorInput`s, with the proposed `customEditorDiffs` capabilities (`supportsInlineDiff`, `supportsSideBySideDiff`, used by markdown-language-features' preview); so `activeCustomEditorTextDiff` (contextkeys.ts) is never set and Reopen as Text (editor.contribution.ts `ReOpenInTextEditorAction`, `enableInModalMode`) is missing from the editor title and the modal header | cargo test -p app custom_editors each_group_s_custom_text_editor_has_its_own_webview a_custom_text_editor_s_navigation_drives_the_outline a_custom_document_open_in_another_group_moves_to_the_active_one a_custom_document_with_multiple_editors_opens_one_more_in_the_active_group a_workspace_association_wins_over_a_user_one_of_the_same_length a_reopened_preview_keeps_its_tab_position two_default_editors_for_a_resource_ask_once_which_to_keep markdown_editor_files_offer; `FIXTURE=custom-editor-tests port/tools/webview-check` 8/8 |-| workbench/contrib/debug | workbench contribution | M16 | ported | [3 M] variable_menu.rs: no View Binary Data: debug.contribution.ts registers it only in the rows' `inline` group, and the port's Variables, Watch and hover rows have no inline action bar, no `vscode-debug-memory` file system and no hex editor install prompt (variablesView.ts `VIEW_MEMORY_ID`) <br> [3 S] debug_configuration: a picked dynamic configuration keeps its name but not its type (debugConfigurationManager.ts `selectedType`, `DEBUG_SELECTED_TYPE`), so the Run and Debug dropdown and F5 fall back to launch.json's first configuration and the dropdown lists no recent dynamic configurations (debugActionViewItems.ts) <br> [3 M] debug_editor: no inline breakpoint widgets: neither the candidate dots (breakpointEditorContribution.ts `requestBreakpointCandidateLocations`, `breakpointLocations` request on the breakpoints' lines) nor the `InlineBreakpointWidget` of a column breakpoint (ui-pair `debug/variables-menu.json`, line 5 of app.js) | cargo test -p app debug launch_picker_shrinks the_debug_container_more_actions debug_service a_workbench_hover_draws_over_the_debug_hover the_tree_height_keeps_an_above_hover_off_the_hovered_line watch_expression_labels_use_the_monospace_font debug_view debug_task_runner debug_commands debug_console debug::ansi an_ended_session_stays_in_the_picker_until_cleared_or_started_again a_start_or_restart_saves_the_dirty_editors a_hit_breakpoint_enables_its_dependents debug_inline_values debug_hover alt_click_toggles_the_loaded_subtree a_click_on_a_hover_row_focuses_the_tree a_lazy_row_takes_its_value_from_the_eye_button the_find_widget_filters_the_hover_tree disassembly list_tree a_step_in_the_disassembly_view debug::tests::instruction_breakpoints debug::tests::remove_instruction_breakpoints a_right_clicked_call_stack_row_takes_the_list_focus the_debug_toolbar_and_create_configuration_menus_take_contributed_items debug_toolbar variable_menu a_stop_on_a_line_in_view_keeps_the_scroll the_debug_picker_lists_and_starts_the_launch_configurations the_first_scope_expands_only_once_the_variables_view_exists the_find_widget_filters_the_console a_variable_row_draws_its_scopes_indent_guide a_top_frame_past_column_1_injects_the_column_arrow the_call_stack_selects_the_focused_frame_only_after_a_focus_change_it_saw a_visualized_child_shows_its_tree_in_the_hover a_watch_expressions_visualized_child_draws_its_tree; ui-pair port/fixtures/debug-node (breakpoint, F5, views, REPL, toolbar, `greeting` and `numbers` hovers), menus/view-container-title.json, port/fixtures/ui-pair/debug/hover-find.json, port/fixtures/ui-pair/debug/unverified-breakpoints.json, port/fixtures/ui-pair/debug/call-stack-menu.json, port/fixtures/ui-pair/debug/toolbar.json, port/fixtures/ui-pair/debug/variables-menu.json, port/fixtures/ui-pair/debug/lazy-variable.json, port/fixtures/ui-pair/debug/quick-access.json; shortcuts in port/notes.md |+| workbench/contrib/debug | workbench contribution | M16 | ported | [3 M] variable_menu.rs: no View Binary Data: debug.contribution.ts registers it only in the rows' `inline` group, and the port's Variables, Watch and hover rows have no inline action bar, no `vscode-debug-memory` file system and no hex editor install prompt (variablesView.ts `VIEW_MEMORY_ID`) <br> [3 M] debug_editor: no inline breakpoint widgets: neither the candidate dots (breakpointEditorContribution.ts `requestBreakpointCandidateLocations`, `breakpointLocations` request on the breakpoints' lines) nor the `InlineBreakpointWidget` of a column breakpoint (ui-pair `debug/variables-menu.json`, line 5 of app.js) | cargo test -p app debug launch_picker_shrinks the_debug_container_more_actions debug_service a_workbench_hover_draws_over_the_debug_hover the_tree_height_keeps_an_above_hover_off_the_hovered_line watch_expression_labels_use_the_monospace_font debug_view debug_task_runner debug_commands debug_console debug::ansi an_ended_session_stays_in_the_picker_until_cleared_or_started_again a_start_or_restart_saves_the_dirty_editors a_hit_breakpoint_enables_its_dependents debug_inline_values debug_hover alt_click_toggles_the_loaded_subtree a_click_on_a_hover_row_focuses_the_tree a_lazy_row_takes_its_value_from_the_eye_button the_find_widget_filters_the_hover_tree disassembly list_tree a_step_in_the_disassembly_view debug::tests::instruction_breakpoints debug::tests::remove_instruction_breakpoints a_right_clicked_call_stack_row_takes_the_list_focus the_debug_toolbar_and_create_configuration_menus_take_contributed_items debug_toolbar variable_menu a_stop_on_a_line_in_view_keeps_the_scroll the_debug_picker_lists_and_starts_the_launch_configurations the_first_scope_expands_only_once_the_variables_view_exists the_find_widget_filters_the_console a_variable_row_draws_its_scopes_indent_guide a_top_frame_past_column_1_injects_the_column_arrow the_call_stack_selects_the_focused_frame_only_after_a_focus_change_it_saw a_visualized_child_shows_its_tree_in_the_hover a_watch_expressions_visualized_child_draws_its_tree a_dynamic_selection_keeps_its_type_for_f5; ui-pair port/fixtures/debug-node (breakpoint, F5, views, REPL, toolbar, `greeting` and `numbers` hovers), menus/view-container-title.json, port/fixtures/ui-pair/debug/hover-find.json, port/fixtures/ui-pair/debug/unverified-breakpoints.json, port/fixtures/ui-pair/debug/call-stack-menu.json, port/fixtures/ui-pair/debug/toolbar.json, port/fixtures/ui-pair/debug/variables-menu.json, port/fixtures/ui-pair/debug/lazy-variable.json, port/fixtures/ui-pair/debug/quick-access.json; shortcuts in port/notes.md || workbench/contrib/dropOrPasteInto | workbench contribution | M13 | verified | | commands.ts `configurePreferredPasteAction`/`configurePreferredDropAction`: the widgets' menus and the Paste As pick open user settings JSON at `editor.pasteAs.preferences` or `editor.dropIntoEditor.preferences` (workbench/paste_edits.rs); the `editor.pasteAs.*` and `editor.dropIntoEditor.*` settings come from core-settings.json; ui-pair paste-menu (port/results/language-features.md) || workbench/contrib/editSessions | workbench contribution | | removed | | no sign-in/AI by decision (port/notes.md); not ported || workbench/contrib/editTelemetry | workbench contribution | | removed | | no AI or Microsoft services by decision (port/notes.md); API stays inert |