Visual Studio Code, rebuilt in Rust
Rust
fix(debug): select the focused frame only after a seen focus change
rokartur792afb3f08ee
diff --git a/native/crates/app/src/workbench.rs b/native/crates/app/src/workbench.rsindex c556d1e6cf8..47dc84df736 100644--- a/native/crates/app/src/workbench.rs+++ b/native/crates/app/src/workbench.rs@@ -633,7 +633,7 @@ impl Render for Workbench {self.refresh_selection_highlights(window);self.refresh_document_highlights(window, cx);self.refresh_outline_pane(cx);- self.mark_variables_view_created();+ self.mark_debug_views_created();self.update_webview_panels(window, cx);self.update_notebook_views(window, cx);self.update_diff_editor();diff --git a/native/crates/app/src/workbench/debug_service.rs b/native/crates/app/src/workbench/debug_service.rsindex 60b899c6a8b..94a4b592f8f 100644--- a/native/crates/app/src/workbench/debug_service.rs+++ b/native/crates/app/src/workbench/debug_service.rs@@ -953,6 +953,7 @@ impl Workbench {self.debug.scopes.clear();self.debug.children.clear();self.debug_view.expand_first_scope = self.debug_view.variables_view_created || self.is_view_visible(super::debug_view::VARIABLES_VIEW);+ self.debug_view.call_stack_selects_focus = self.debug_view.call_stack_view_created || self.is_view_visible(super::debug_view::CALL_STACK_VIEW);self.disassembly_focus_changed(cx);if reveal != Reveal::No && let Some(frame) = self.debug.focused_frame().cloned() {self.reveal_stack_frame(&frame, reveal == Reveal::PreservingFocus, window, cx);diff --git a/native/crates/app/src/workbench/debug_view.rs b/native/crates/app/src/workbench/debug_view.rsindex 68ea320189d..4332ca539b2 100644--- a/native/crates/app/src/workbench/debug_view.rs+++ b/native/crates/app/src/workbench/debug_view.rs@@ -73,6 +73,10 @@ pub struct DebugView {/// A focus change expands the first scope only when the Variables view exists by then: `renderBody` sets the/// input it finds without expanding (variablesView.ts).pub expand_first_scope: bool,+ /// callStackView.ts builds its tree in `renderBody` too, and selects the focused frame only on a focus change after.+ pub call_stack_view_created: bool,+ /// Whether the Call Stack view existed at the last focus change (`updateTreeSelection` ran on it).+ pub call_stack_selects_focus: bool,/// variablesView.ts `variableInternalContext`: the variable row of the last variable menu, which Set Value edits.pub menu_variable: Option<Editing>,/// debugCommands.ts `dataBreakpointInfoResponse`: the last variable menu's `dataBreakpointInfo` answer.@@ -104,6 +108,8 @@ impl DebugView {exception: None,variables_view_created: false,expand_first_scope: false,+ call_stack_view_created: false,+ call_stack_selects_focus: false,menu_variable: None,data_breakpoint_info: None,edit_error: None,@@ -121,10 +127,13 @@ const INDENT: f32 = 8.;pub(super) type DebugTreeRow = (gpui::AnyElement, usize, bool);impl Workbench {- pub(super) fn mark_variables_view_created(&mut self) {+ pub(super) fn mark_debug_views_created(&mut self) {if !self.debug_view.variables_view_created && self.is_view_visible(VARIABLES_VIEW) {self.debug_view.variables_view_created = true;}+ if !self.debug_view.call_stack_view_created && self.is_view_visible(CALL_STACK_VIEW) {+ self.debug_view.call_stack_view_created = true;+ }}/// `CONTEXT_DEBUG_UX` `simple`: no session and no launch configuration, the welcome view instead of the debug views.@@ -745,7 +754,7 @@ impl Workbench {rows.push((self.debug_row(format!("frame/{}/{}", session.id, frame.id), frame_depth, None, false, list_focused, cx).justify_center().italic().text_color(self.color("descriptionForeground")).child(frame.name.clone()).on_mouse_down(MouseButton::Right, frame_menu).into_any_element(), frame_depth, false));continue;}- let focused = self.debug.focus.session.as_deref() == Some(session.id.as_str()) && self.debug.focus.frame == Some(frame.id);+ let focused = self.debug_view.call_stack_selects_focus && self.debug.focus.session.as_deref() == Some(session.id.as_str()) && self.debug.focus.frame == Some(frame.id);let (session_id, thread_id, frame_id) = (session.id.clone(), thread.id, frame.id);let row = self.debug_row(format!("frame/{}/{}", session.id, frame.id), frame_depth, None, focused, list_focused, cx)@@ -1248,6 +1257,22 @@ mod tests {assert_eq!(outline, row);}+ /// callStackView.ts: a Call Stack view first shown after the stop (`openOnDebugBreak`) builds its tree without the+ /// selection; `updateTreeSelection` selects the focused frame from the next focus change on.+ #[gpui::test]+ fn the_call_stack_selects_the_focused_frame_only_after_a_focus_change_it_saw(cx: &mut TestAppContext) {+ let (workbench, cx, _host) = super::super::variable_menu::tests::stopped_session(cx, json!({}));+ let focus = super::super::debug_service::DebugFocus { session: Some("s".into()), thread: Some(1), frame: Some(9) };+ let selects = |workbench: &gpui::Entity<Workbench>, cx: &mut gpui::VisualTestContext| workbench.read_with(cx, |workbench, _| workbench.debug_view.call_stack_selects_focus);+ workbench.update_in(cx, |workbench, window, cx| workbench.set_debug_focus(focus.clone(), super::super::debug_service::Reveal::No, window, cx));+ assert!(!selects(&workbench, cx), "the view does not exist yet");+ workbench.update(cx, |workbench, cx| workbench.show_debug_view(cx));+ cx.update(|window, cx| drop(window.draw(cx)));+ assert!(!selects(&workbench, cx), "showing the view keeps the selection empty");+ workbench.update_in(cx, |workbench, window, cx| workbench.set_debug_focus(focus, super::super::debug_service::Reveal::No, window, cx));+ assert!(selects(&workbench, cx));+ }+/// debugViewlet.css `.debug-pane .scope`: font-weight bold, font-size 11px.#[gpui::test]fn scope_rows_draw_at_11px(cx: &mut TestAppContext) {diff --git a/port/ledger.md b/port/ledger.mdindex 8f2a8edde09..d4e4ec7c0fb 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_view.rs: the focused frame's Call Stack row draws `list.inactiveSelectionBackground` where the reference's, with js-debug's compact child session, draws none (ui-pair `debug/variables-menu.json` stopped.png; callStackView.ts `updateTreeSelection`, why its selection does not show not traced) <br> [3 M] debug_visualizers.rs: visualized rows draw only in the Variables view; the Watch view's and the debug hover's expression children keep their plain rows (watchExpressionsView.ts:98, debugHover.ts:142 register `VisualizedVariableRenderer`) <br> [3 S] debug_service.rs: `guess_debugger`'s Select Debugger picker has no "More {0} options..." picks of the dynamic configuration providers (debugAdapterManager.ts `getDynamicProviders`), which the port does not have <br> [3 S] debugQuickAccess.ts: the picker has no dynamic configuration providers' `{label}...` picks with the `contributed` description, where the reference lists `Node.js...` (ui-pair `debug/quick-access.json`, `FOLDER=port/fixtures/debug-node`) <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; 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_visualizers.rs: visualized rows draw only in the Variables view; the Watch view's and the debug hover's expression children keep their plain rows (watchExpressionsView.ts:98, debugHover.ts:142 register `VisualizedVariableRenderer`) <br> [3 S] debug_service.rs: `guess_debugger`'s Select Debugger picker has no "More {0} options..." picks of the dynamic configuration providers (debugAdapterManager.ts `getDynamicProviders`), which the port does not have <br> [3 S] debugQuickAccess.ts: the picker has no dynamic configuration providers' `{label}...` picks with the `contributed` description, where the reference lists `Node.js...` (ui-pair `debug/quick-access.json`, `FOLDER=port/fixtures/debug-node`) <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; 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 |diff --git a/port/notes.md b/port/notes.mdindex 23cf092cc1c..bf3141c5724 100644--- a/port/notes.md+++ b/port/notes.md@@ -880,6 +880,7 @@ Scope as in the M19 Work row of port/ledger.md.- Continuous run (`workbench/testing_continuous.rs`): the view title's dropdown of `getContinuousRunDropdown` runs plain actions upstream; the port's context menu runs commands, so each profile item is an internal `_testing.toggleContinuousRunProfile.<controller>.<profile>` command registered when the menu shows. testingExplorerView.ts re-sorts a parent when a continuous run changes, but `TreeSorter` has no continuous run criterion in 1.147.0, so the order does not change; the port draws rows from the run state each frame and needs no re-sort. The unattended restart participant `testing.continuousRun` waits on the unattended restart service (ledger row workbench/services/lifecycle).- Inline values (`workbench/debug_inline_values.rs`; debugEditorContribution.ts): `debug.inlineValues` `on` or `auto` with a provider shows the focused frame's values as `InjectionOwner::DebugInlineValue` text after the lines, `editor.inlineValuesForeground` on `editor.inlineValuesBackground`. Shortcuts: only the active editor shows them, where upstream decorates every editor on the frame's file; the scopes and variables are fetched again, not shared with the Variables view's cache; the text area width stands in for `layoutInfo.width` in the line length cut.- Debug hover (`workbench/debug_hover.rs`; debugHover.ts, debugEditorContribution.ts hover handling): while stopped, the expression at the mouse in the focused frame's file (the first `EvaluatableExpressionProvider` through `$provideEvaluatableExpression`, else `getExactExpressionStartAndEnd`) is evaluated with `context: "hover"` (or looked up in the cheap scopes without `supportsEvaluateForHovers`) after the doubled `editor.hover.delay`, the editor hover off meanwhile; Alt swaps it for the editor hover; Cmd+K Cmd+I shows it at the cursor. The focused tree takes listWidget.ts's and abstractTree.ts's keys through the `list.*` commands (Up, Down, Page Up, Page Down, Home, End, Left, Right, Space, Enter, type navigation by name), Escape clears a selection before it hides the widget; `layoutTree` sizes the tree to its rows plus 10px, at most max(266px, 55% of the editor) and the hovered line's top less 22px. The visualizers are a ledger gap of workbench/contrib/debug; the context menu is under Variable menus. The glyph margin lifts the editor hover lockout; the hovered position is the nearer edge of the character under the mouse, a tab's middle included. Lazy rows (`presentationHint.lazy`) draw the `$(eye)` button after the name in the hover, Variables and Watch trees; a lazy watch, hover or REPL result is evaluated at once (debugModel.ts `evaluateExpression` without `keepLazyVars`). A click on an expandable row focuses and toggles it; with Alt the descendants whose children are loaded follow, the others stay collapsed (indexTreeModel.ts `_setNodeCollapseState` recursive, asyncDataTree.ts collapsing a stale node a deep expand reaches). `list.find` (Cmd+Alt+F, F3) on the focused tree opens abstractTree.ts's find widget over 30px of padding: highlight or filter mode and fuzzy or contiguous match by `workbench.list.defaultFindMode` and `defaultFindMatchType` and the widget's toggles, the filter keeps a collapsed parent of a loaded match, "No results found.", the focus to the first match from the focused row; it outlives each shown value like the tree, and Escape hides the hover and runs `list.closeFind` after it. ui-pair on `port/fixtures/debug-node` (Cmd+K Cmd+I on `numbers` and `greeting`) matches the reference's placement, tree indent and focus outline.+- Call Stack selection (`workbench/debug_view.rs` `call_stack_selects_focus`; callStackView.ts `updateTreeSelection`): the view builds its tree in `renderBody` and selects the focused frame only on a focus change it sees, so a view first shown by `openOnDebugBreak` after the stop has no selected row until the next focus change. Measured with `port/tools/ref-dom` on `port/fixtures/debug-node` app.js: the first stop leaves no `.monaco-list-row.selected`; after Continue to a second breakpoint `global.main app.js 5:2` is selected; with the Run and Debug view shown before the start the first stop selects it too.- Variable menus (`workbench/variable_menu.rs`; variablesView.ts `openContextMenuForVariableTreeElement`, watchExpressionsView.ts `onContextMenu`, debugContext.ts `getContextForVariable`): a right-click on a Variables, Watch or hover row opens `DebugVariablesContext`, `DebugWatchContext` or `DebugHoverContext` over the row's keys (`variableEvaluateNamePresent`, `variableIsReadonly`, `variableType`, `watchItemType`, `debugType`), with `{ sessionId, container, variable }` for a variable and `{ watchExpressionId, name }` for a watch expression. Copy Value evaluates `evaluateName || value` again with the `clipboard` context when the debugger supports it, else `variables` or `watch`, and falls back to the shown value. Set Value, View Binary Data and the Break on Value items are left out until their requests are ported (ledger debug row); `canViewMemory` is always false.- Debug Console find (`workbench/debug_console_find.rs`; repl.ts `FindReplAction`, `openFind`): `repl.action.find` (Cmd+Alt+F, the title's `search` before the session picker and Clear Console) opens the tree find widget of the debug hover (`TreeFind`) over the console with 30px of padding; elements are found by `IReplElement.toString(true)`, an evaluation by its input or its result, filter mode drops the elements without a match, evaluation inputs and variable names highlight the matched chars, "No results found." when nothing matches, the pattern is kept for the next open. Shortcuts: the port's console has no row focus, so highlight mode moves no focus to the first match; the item in `MenuId.DebugConsoleContext` waits on that menu, which the port does not have (cargo test -p app the_find_widget_filters_the_console).- Extension host debugging (`extensionHost` launch type; rawDebugSession.ts `launchVsCode`, localProcessExtensionHost.ts `attachSession`, debugService.ts `onAttachSession`): js-debug's `launchVSCode` opens the Extension Development Host window (or reloads the one on the same extension path) with `--debugId`, `--inspect-brk-extensions` and `--extensionEnvironment`; the host it starts has the session attach to the inspector port on a new adapter. Decision: a host with an inspector port runs on Node, since Bun has no V8 inspector; a host without one stays on Bun, and there is no 5870 default port (environmentService.ts gives one to a build from source, which would put every checkout run on Node). The window closes with its current host's exit and at the end of a 'Run Without Debugging' session; a restart reloads it. Check: `cargo test -p app workbench::host::`, ui-pair `debug/extension-host.json` with `FOLDER=port/fixtures/debug-extension` (stops at the breakpoint in `activate`).