Visual Studio Code, rebuilt in Rust
Rust
feat(debug): draw visualized rows in the debug hover
rokarturbc385910ca0d
diff --git a/native/crates/app/src/workbench/debug_hover.rs b/native/crates/app/src/workbench/debug_hover.rsindex 435b99f7864..f061c4bc110 100644--- a/native/crates/app/src/workbench/debug_hover.rs+++ b/native/crates/app/src/workbench/debug_hover.rs@@ -1,6 +1,7 @@//! debugHover.ts and the hover handling of debugEditorContribution.ts: while a session is stopped, the value of the//! expression under the mouse in the focused frame's file takes the place of the editor hover; Alt switches back.+use std::borrow::Cow;use std::cell::Cell;use std::collections::HashSet;use std::ops::Range;@@ -13,11 +14,12 @@ use gpui::{canvas, deferred, div, point, prelude::*, px, rgba,};use regex::Regex;-use serde_json::json;+use serde_json::{Value, json};use super::Workbench;use super::content_hover::{Anchor, HoverSource, MouseTarget, anchor_at};use super::debug_service::{answer, evaluate_lazy, on_workbench};+use super::debug_visualizers::RowKey;use super::explorer_find::{TreeFindLook, label_matches};use super::find_widget::HISTORY_LIMIT;use super::input_box_view::{InputId, InputView};@@ -146,12 +148,30 @@ struct TreeRow<'a> {key: String,depth: usize,parent_reference: i64,- variable: &'a Variable,+ /// A visualized item's label and description stand in for its name and value.+ variable: Cow<'a, Variable>,+ source: RowSource,+ children: HoverChildren,expanded: bool,/// The find pattern's matched chars in the name.highlights: Vec<Range<usize>>,}+/// The tree element a row draws: a `Variable`, or a `VisualizedExpression` whose `original` (only the visualized+/// variable, not the tree's children) shows Remove Visualizer.+enum RowSource {+ Variable,+ Visualized { original: Option<RowKey> },+}++/// Where an expanded row's children come from.+#[derive(Clone)]+enum HoverChildren {+ None,+ Variables(i64),+ Visualized(String, i64),+}+#[derive(Debug, PartialEq)]enum ShowResult {Shown,@@ -552,14 +572,40 @@ impl Workbench {continue;}let key = format!("{parent}/{}", variable.name);+ let original: RowKey = (session.to_owned(), reference, variable.name.clone());+ if let Some(visualized) = self.debug.visualizers.visualized.get(&original) {+ self.collect_visualized_hover_rows(&visualized.tree_id, &visualized.item, Some(original), key, depth, rows);+ continue;+ }let expanded = variable.has_children() && self.debug_hover.expanded.contains(&key);- rows.push(TreeRow { key: key.clone(), depth, parent_reference: reference, variable, expanded, highlights: highlights.unwrap_or_default() });+ let children = if variable.has_children() { HoverChildren::Variables(variable.variables_reference) } else { HoverChildren::None };+ let row = TreeRow { key: key.clone(), depth, parent_reference: reference, variable: Cow::Borrowed(variable), source: RowSource::Variable, children, expanded, highlights: highlights.unwrap_or_default() };+ rows.push(row);if expanded {self.collect_debug_hover_rows(session, variable.variables_reference, &key, depth + 1, query, rows);}}}+ /// debugHover.ts registers `VisualizedVariableRenderer`: a visualized row, then its expanded tree children.+ fn collect_visualized_hover_rows<'a>(&'a self, tree_id: &str, item: &Value, original: Option<RowKey>, key: String, depth: usize, rows: &mut Vec<TreeRow<'a>>) {+ let item_id = item["id"].as_i64().unwrap_or_default();+ // DebugTreeItemCollapsibleState.None+ let expandable = item["collapsibleState"].as_u64().unwrap_or_default() != 0;+ let expanded = expandable && self.debug_hover.expanded.contains(&key);+ let variable = Variable { name: item["label"].as_str().unwrap_or_default().to_owned(), value: item["description"].as_str().unwrap_or_default().to_owned(), ..Variable::default() };+ let children = if expandable { HoverChildren::Visualized(tree_id.to_owned(), item_id) } else { HoverChildren::None };+ rows.push(TreeRow { key: key.clone(), depth, parent_reference: 0, variable: Cow::Owned(variable), source: RowSource::Visualized { original }, children, expanded, highlights: Vec::new() });+ if !expanded {+ return;+ }+ let Some(children) = self.debug.visualizers.tree_children.get(&(tree_id.to_owned(), item_id)) else { return };+ for child in children {+ let child_key = format!("{key}/{}", child["id"].as_i64().unwrap_or_default());+ self.collect_visualized_hover_rows(tree_id, child, None, child_key, depth + 1, rows);+ }+ }+/// indexTreeModel.ts `_updateNodeAfterFilterChange`: the loaded children are filtered, collapsed or not./// `visited` stops at a reference an adapter hands out twice.fn debug_hover_descendant_matches(&self, session: &str, variable: &Variable, query: &FindQuery, visited: &mut HashSet<i64>) -> bool {@@ -692,39 +738,48 @@ impl Workbench {/// A `VariablesRenderer` row; a click toggles an expandable one without focusing the tree (`mouseSupport: false`).fn debug_hover_row(&self, row: TreeRow<'_>, session: &str, tree_focused: bool, cx: &mut Context<Self>) -> AnyElement {- let expandable = row.variable.has_children();+ let expandable = !matches!(row.children, HoverChildren::None);let foreground = self.foreground_or("icon.foreground");// tree.css `.monaco-tl-twistie`: 16px wide, `padding-right: 6px`, the chevron moved 3px right.let twistie = div().id("twistie").w(px(22.)).pl(px(3.)).pr(px(3.)).flex_none().when(expandable, |twistie| {twistie.child(self.icon(if row.expanded { "chevron-down" } else { "chevron-right" }, 16., 16., foreground))});- let (key, session_id, reference, expanded) = (row.key.clone(), session.to_owned(), row.variable.variables_reference, row.expanded);+ let (key, session_id, children, expanded) = (row.key.clone(), session.to_owned(), row.children.clone(), row.expanded);// abstractTree.ts `onViewPointer`: a twistie click only toggles, a row click toggles and then focuses and selects.let twistie = twistie.when(expandable, |twistie| {- let (key, session_id) = (key.clone(), session_id.clone());+ let (key, session_id, children) = (key.clone(), session_id.clone(), children.clone());twistie.on_click(cx.listener(move |workbench, event: &ClickEvent, window, cx| {cx.stop_propagation();- workbench.toggle_debug_hover_row(&key, &session_id, reference, !expanded, event.modifiers().alt, window, cx);+ workbench.toggle_debug_hover_row(&key, &session_id, &children, !expanded, event.modifiers().alt, window, cx);}))});// abstractTree.ts `TreeRenderer.DefaultIndent` (8px) plus `workbench.tree.indent` per level.let indent = 8. + INDENT * row.depth as f32;- let lazy_button = row.variable.is_lazy().then(|| self.lazy_button(session, row.parent_reference, row.variable, &row.key, cx));- let mut element = div().id(gpui::SharedString::from(row.key.clone())).h(px(ROW_HEIGHT)).flex().items_center().pl(px(indent)).child(twistie).child(self.expression_label(row.variable, &row.highlights, lazy_button).font_family(super::debug_view::EXPRESSION_FONT).text_size(px(super::debug_view::EXPRESSION_FONT_SIZE)));+ let lazy_button = row.variable.is_lazy().then(|| self.lazy_button(session, row.parent_reference, &row.variable, &row.key, cx));+ let focused = self.debug_hover.focused.as_ref() == Some(&row.key);+ let group = gpui::SharedString::from(row.key.clone());+ let actions = match &row.source {+ RowSource::Variable => self.visualizer_actions(&(session.to_owned(), row.parent_reference, row.variable.name.clone()), &group, focused, cx),+ RowSource::Visualized { original: Some(original) } => Some(self.remove_visualizer_action(&row.key, original.clone(), &group, focused, cx)),+ RowSource::Visualized { original: None } => None,+ };+ let label = self.expression_label(&row.variable, &row.highlights, lazy_button).font_family(super::debug_view::EXPRESSION_FONT).text_size(px(super::debug_view::EXPRESSION_FONT_SIZE));+ let mut element = div().id(group.clone()).group(group).h(px(ROW_HEIGHT)).flex().items_center().pl(px(indent)).child(twistie).child(label).children(actions);element = element.on_click(cx.listener(move |workbench, event: &ClickEvent, window, cx| {if expandable {- workbench.toggle_debug_hover_row(&key, &session_id, reference, !expanded, event.modifiers().alt, window, cx);+ workbench.toggle_debug_hover_row(&key, &session_id, &children, !expanded, event.modifiers().alt, window, cx);}workbench.debug_hover.focused = Some(key.clone());workbench.debug_hover.selected = Some(key.clone());cx.notify();}));- let (menu_session, parent_reference, variable) = (session.to_owned(), row.parent_reference, row.variable.clone());- element = element.on_mouse_down(MouseButton::Right, cx.listener(move |workbench, event: &MouseDownEvent, window, cx| {- let row = VariableMenuRow::Variable { menu: MenuId::DebugHoverContext, session: menu_session.clone(), parent_reference, variable: variable.clone() };- workbench.show_variable_menu(row, Bounds::new(event.position, Default::default()), window, cx);- }));- let focused = self.debug_hover.focused.as_ref() == Some(&row.key);+ if let RowSource::Variable = row.source {+ let (menu_session, parent_reference, variable) = (session.to_owned(), row.parent_reference, row.variable.clone().into_owned());+ element = element.on_mouse_down(MouseButton::Right, cx.listener(move |workbench, event: &MouseDownEvent, window, cx| {+ let row = VariableMenuRow::Variable { menu: MenuId::DebugHoverContext, session: menu_session.clone(), parent_reference, variable: variable.clone() };+ workbench.show_variable_menu(row, Bounds::new(event.position, Default::default()), window, cx);+ }));+ }let selected = self.debug_hover.selected.as_ref() == Some(&row.key);// debugHover.css takes the hover background off the rows.if focused || selected {@@ -736,11 +791,11 @@ impl Workbench {/// abstractTree.ts `TreeMouseController.onViewPointer` on an expandable row: it takes the focus and toggles, with/// Alt recursively.#[allow(clippy::too_many_arguments, reason = "the row and the click")]- fn toggle_debug_hover_row(&mut self, key: &str, session: &str, reference: i64, expand: bool, recursive: bool, window: &mut Window, cx: &mut Context<Self>) {+ fn toggle_debug_hover_row(&mut self, key: &str, session: &str, children: &HoverChildren, expand: bool, recursive: bool, window: &mut Window, cx: &mut Context<Self>) {self.debug_hover.focused = Some(key.to_owned());- self.set_debug_hover_row_expanded(key, session, reference, expand, window, cx);- if recursive {- self.set_debug_hover_descendants_expanded(key, session, reference, expand);+ self.set_debug_hover_row_expanded(key, session, children, expand, window, cx);+ if let (true, HoverChildren::Variables(reference)) = (recursive, children) {+ self.set_debug_hover_descendants_expanded(key, session, *reference, expand);}}@@ -748,9 +803,9 @@ impl Workbench {let Some(shown) = self.focused_debug_hover_tree(window) else { return };let session = shown.session_id.clone();let Some(focused) = self.debug_hover.focused.clone() else { return };- let Some((reference, expanded)) = self.debug_hover_tree_rows(shown).iter().find(|row| row.key == focused).map(|row| (row.variable.variables_reference, row.expanded)) else { return };- if reference > 0 {- self.toggle_debug_hover_row(&focused, &session, reference, !expanded, true, window, cx);+ let Some((children, expanded)) = self.debug_hover_tree_rows(shown).iter().find(|row| row.key == focused).map(|row| (row.children.clone(), row.expanded)) else { return };+ if !matches!(children, HoverChildren::None) {+ self.toggle_debug_hover_row(&focused, &session, &children, !expanded, true, window, cx);}}@@ -773,11 +828,15 @@ impl Workbench {}}- fn set_debug_hover_row_expanded(&mut self, key: &str, session: &str, reference: i64, expand: bool, window: &mut Window, cx: &mut Context<Self>) {+ fn set_debug_hover_row_expanded(&mut self, key: &str, session: &str, children: &HoverChildren, expand: bool, window: &mut Window, cx: &mut Context<Self>) {if !expand {self.debug_hover.expanded.remove(key);} else if self.debug_hover.expanded.insert(key.to_owned()) {- self.fetch_children(session, reference, window, cx);+ match children {+ HoverChildren::Variables(reference) => self.fetch_children(session, *reference, window, cx),+ HoverChildren::Visualized(tree_id, item_id) => self.fetch_visualized_children(tree_id, *item_id, window, cx),+ HoverChildren::None => {}+ }}cx.notify();}@@ -787,7 +846,7 @@ impl Workbench {pub(super) fn debug_hover_list_command(&mut self, id: &str, window: &mut Window, cx: &mut Context<Self>) -> bool {let Some(shown) = self.focused_debug_hover_tree(window) else { return false };let session = shown.session_id.clone();- let rows: Vec<(String, usize, i64, bool)> = self.debug_hover_tree_rows(shown).iter().map(|row| (row.key.clone(), row.depth, row.variable.variables_reference, row.expanded)).collect();+ let rows: Vec<(String, usize, HoverChildren, bool)> = self.debug_hover_tree_rows(shown).iter().map(|row| (row.key.clone(), row.depth, row.children.clone(), row.expanded)).collect();if rows.is_empty() {return true;}@@ -811,13 +870,12 @@ impl Workbench {}"list.expand" | "list.collapse" | "list.toggleExpand" => {let Some(index) = focus else { return true };- let (key, depth, reference, expanded) = &rows[index];- // Variable::has_children.- let expandable = *reference > 0;+ let (key, depth, children, expanded) = &rows[index];+ let expandable = !matches!(children, HoverChildren::None);match id {- "list.toggleExpand" if expandable => self.set_debug_hover_row_expanded(key, &session, *reference, !expanded, window, cx),- "list.expand" if expandable && !expanded => self.set_debug_hover_row_expanded(key, &session, *reference, true, window, cx),- "list.collapse" if *expanded => self.set_debug_hover_row_expanded(key, &session, *reference, false, window, cx),+ "list.toggleExpand" if expandable => self.set_debug_hover_row_expanded(key, &session, children, !expanded, window, cx),+ "list.expand" if expandable && !expanded => self.set_debug_hover_row_expanded(key, &session, children, true, window, cx),+ "list.collapse" if *expanded => self.set_debug_hover_row_expanded(key, &session, children, false, window, cx),"list.expand" if rows.get(index + 1).is_some_and(|child| child.1 > *depth) => self.focus_debug_hover_row(&rows[index + 1].0, index + 1, list, cx),"list.collapse" => {if let Some(parent) = rows[..index].iter().rposition(|parent| parent.1 < *depth) {@@ -892,7 +950,7 @@ impl Workbench {let rows = self.debug_hover_tree_rows(shown);let Some(index) = self.debug_hover.focused.as_ref().and_then(|focused| rows.iter().position(|row| row.key == *focused)) else { return };let row = &rows[index];- let expandable = row.variable.has_children();+ let expandable = !matches!(row.children, HoverChildren::None);context.insert("treeElementCanCollapse".into(), json!(expandable && row.expanded));context.insert("treeElementCanExpand".into(), json!(expandable && !row.expanded));context.insert("treeElementHasChild".into(), json!(rows.get(index + 1).is_some_and(|child| child.depth > row.depth)));diff --git a/native/crates/app/src/workbench/debug_hover/tests.rs b/native/crates/app/src/workbench/debug_hover/tests.rsindex 9d7b1426e18..48ac9413ae3 100644--- a/native/crates/app/src/workbench/debug_hover/tests.rs+++ b/native/crates/app/src/workbench/debug_hover/tests.rs@@ -291,7 +291,7 @@ fn alt_click_toggles_the_loaded_subtree(cx: &mut TestAppContext) {respond(&workbench, &host, &[("evaluate", json!({ "result": "Object", "variablesReference": 7 }))], cx);respond(&workbench, &host, &[("variables", json!({ "variables": [{ "name": "alpha", "value": "Object", "variablesReference": 8 }] }))], cx);let toggle = |key: &str, reference: i64, expand: bool, alt: bool, cx: &mut VisualTestContext| {- workbench.update_in(cx, |workbench, window, cx| workbench.toggle_debug_hover_row(key, "s", reference, expand, alt, window, cx));+ workbench.update_in(cx, |workbench, window, cx| workbench.toggle_debug_hover_row(key, "s", &HoverChildren::Variables(reference), expand, alt, window, cx));cx.run_until_parked();};toggle("hover/alpha", 8, true, false, cx);@@ -370,10 +370,10 @@ fn the_find_widget_filters_the_hover_tree(cx: &mut TestAppContext) {respond(&workbench, &host, &[("evaluate", json!({ "result": "Object", "variablesReference": 7 }))], cx);let children = json!({ "variables": [{ "name": "alpha", "value": "Object", "variablesReference": 8 }, { "name": "beta", "value": "2" }, { "name": "gamma", "value": "3" }] });respond(&workbench, &host, &[("variables", children)], cx);- workbench.update_in(cx, |workbench, window, cx| workbench.toggle_debug_hover_row("hover/alpha", "s", 8, true, false, window, cx));+ workbench.update_in(cx, |workbench, window, cx| workbench.toggle_debug_hover_row("hover/alpha", "s", &HoverChildren::Variables(8), true, false, window, cx));cx.run_until_parked();respond(&workbench, &host, &[("variables", json!({ "variables": [{ "name": "bet", "value": "1" }] }))], cx);- workbench.update_in(cx, |workbench, window, cx| workbench.toggle_debug_hover_row("hover/alpha", "s", 8, false, false, window, cx));+ workbench.update_in(cx, |workbench, window, cx| workbench.toggle_debug_hover_row("hover/alpha", "s", &HoverChildren::Variables(8), false, false, window, cx));workbench.update(cx, |workbench, _| workbench.load_keybindings(crate::keybindings::default_keybindings(&[]), file.parent().unwrap().join("keybindings.json")));workbench.update_in(cx, |workbench, window, cx| window.focus(&workbench.debug_hover_focus, cx));let rows = |cx: &mut VisualTestContext| {@@ -434,6 +434,75 @@ fn a_lazy_row_takes_its_value_from_the_eye_button(cx: &mut TestAppContext) {std::fs::remove_dir_all(file.parent().unwrap()).unwrap();}+/// debugHover.ts registers `VisualizedVariableRenderer`: a hover child offers its visualizers, a used tree+/// visualizer replaces the row with its item, which expands into `$getVisualizerTreeItemChildren`.+#[gpui::test]+fn a_visualized_child_shows_its_tree_in_the_hover(cx: &mut TestAppContext) {+ let file = temp_file("viz", "function f(obj) {\n return obj;\n}\n");+ let (workbench, host, cx) = workbench(cx, &file, json!({ "supportsEvaluateForHovers": true }));+ let tree = "port.viz\0tree";+ workbench.update_in(cx, |workbench, window, cx| {+ let description = json!({ "contributes": { "debugVisualizers": [{ "id": "v", "when": "variableName == 'x'" }] } });+ workbench.extensions.push(exthost::scan::ScannedExtension { id: "port.viz".into(), location: "/viz".into(), description });+ for (method, args) in [("$registerDebugVisualizer", vec![json!("port.viz"), json!("v")]), ("$registerDebugVisualizerTree", vec![json!(tree), json!(false)])] {+ drop(workbench.handle_debug_request(ForwardedRequest { req: 1, proxy: "MainThreadDebugService", method: method.into(), args }, window, cx));+ }+ workbench.editors.active_mut().unwrap().set_selections(vec![crate::editor::Selection::caret(Position::new(1, 10))]);+ drop(workbench.execute_command("editor.debug.action.showDebugHover", Vec::new(), window, cx));+ });+ cx.run_until_parked();+ let visualizers = json!([{ "id": 1, "name": "Tree", "visualization": { "type": 1, "id": tree } }, { "id": 2, "name": "Other" }]);+ let answer = |method: &str| match method {+ "$provideDebugVisualizers" => visualizers.clone(),+ "$getVisualizerTreeItem" => json!({ "id": 7, "label": "x", "description": "tree", "collapsibleState": 1 }),+ "$getVisualizerTreeItemChildren" => json!([{ "id": 8, "label": "child", "description": "c", "collapsibleState": 0 }]),+ _ => Value::Null,+ };+ let drain = |bodies: &[(&str, Value)], cx: &mut VisualTestContext| loop {+ cx.run_until_parked();+ let messages: Vec<HostMessage> = host.try_iter().collect();+ if messages.is_empty() {+ return;+ }+ for message in messages {+ if message.method == "$sendDAMessage" {+ let request = &message.args[1];+ let Some((_, body)) = bodies.iter().find(|(command, _)| request["command"] == *command) else { continue };+ let response = json!({ "type": "response", "seq": 0, "request_seq": request["seq"], "success": true, "command": request["command"], "body": body });+ let accept = ForwardedRequest { req: 1, proxy: "MainThreadDebugService", method: "$acceptDAMessage".into(), args: vec![json!(1), response] };+ workbench.update_in(cx, |workbench, window, cx| drop(workbench.handle_debug_request(accept, window, cx)));+ } else if let Some(reply) = message.reply {+ let _ = reply.send(Ok(answer(message.method)));+ }+ }+ };+ let children = json!({ "variables": [{ "name": "x", "value": "1" }, { "name": "y", "value": "2" }] });+ drain(&[("evaluate", json!({ "result": "Object", "variablesReference": 7 })), ("variables", children)], cx);+ workbench.update(cx, |workbench, cx| {+ workbench.debug_hover.focused = Some("hover/x".into());+ cx.notify();+ });+ cx.run_until_parked();+ assert!(cx.debug_bounds("visualize-variable").is_some(), "the focused x shows its two visualizers behind Visualize Variable...");++ let rows = |cx: &mut VisualTestContext| {+ workbench.read_with(cx, |workbench, _| {+ let shown = workbench.debug_hover.shown.as_ref().unwrap();+ workbench.debug_hover_tree_rows(shown).iter().map(|row| format!("{} {}: {}", row.key, row.variable.name, row.variable.value)).collect::<Vec<_>>()+ })+ };+ workbench.update_in(cx, |workbench, window, cx| workbench.use_visualizer(("s".into(), 7, "x".into()), visualizers[0].clone(), window, cx));+ drain(&[], cx);+ assert_eq!(rows(cx), ["hover/x x: tree", "hover/y y: 2"]);++ workbench.update_in(cx, |workbench, window, cx| window.focus(&workbench.debug_hover_focus, cx));+ workbench.update(cx, |workbench, _| workbench.load_keybindings(crate::keybindings::default_keybindings(&[]), file.parent().unwrap().join("keybindings.json")));+ cx.simulate_keystrokes("right");+ drain(&[], cx);+ assert_eq!(rows(cx), ["hover/x x: tree", "hover/x/8 child: c", "hover/y y: 2"]);+ std::fs::remove_dir_all(file.parent().unwrap()).unwrap();+}+/// The eye button's "Click to expand" hover shows over the debug hover it sits in, so the mouse reaches it.#[gpui::test]fn a_workbench_hover_draws_over_the_debug_hover(cx: &mut TestAppContext) {diff --git a/native/crates/app/src/workbench/debug_visualizers.rs b/native/crates/app/src/workbench/debug_visualizers.rsindex 002f14e48e6..ca1ed9806b5 100644--- a/native/crates/app/src/workbench/debug_visualizers.rs+++ b/native/crates/app/src/workbench/debug_visualizers.rs@@ -205,7 +205,7 @@ impl Workbench {}/// variablesView.ts `useVisualizer`: a command visualizer runs, a tree visualizer replaces the row.- fn use_visualizer(&mut self, row: RowKey, visualizer: Value, window: &mut Window, cx: &mut Context<Self>) {+ pub(super) fn use_visualizer(&mut self, row: RowKey, visualizer: Value, window: &mut Window, cx: &mut Context<Self>) {let id = visualizer["id"].clone();let resolve = visualizer["visualization"].is_null().then(|| self.host.call("ExtHostDebugService", "$resolveDebugVisualizer", vec![id.clone()]));cx.spawn_in(window, async move |this, cx| {@@ -285,6 +285,16 @@ impl Workbench {Some(self.row_action_bar(group, focused).child(button).into_any_element())}+ /// `VisualizedVariableRenderer.renderActionBar` on a visualized variable.+ pub(super) fn remove_visualizer_action(&self, key: &str, original: RowKey, group: &gpui::SharedString, focused: bool, cx: &mut Context<Self>) -> gpui::AnyElement {+ let foreground = self.foreground_or("icon.foreground");+ let button = self.visualizer_button(&format!("{key}/remove-viz"), Some("eye".into()), "Remove Visualizer".into(), foreground).on_click(cx.listener(move |workbench, _: &ClickEvent, _, cx| {+ cx.stop_propagation();+ workbench.remove_visualizer(&original, cx);+ }));+ self.row_action_bar(group, focused).child(button).into_any_element()+ }+fn visualizer_button(&self, id: &str, icon: Option<String>, title: String, foreground: Rgba) -> gpui::Stateful<gpui::Div> {let label = match icon {Some(icon) => self.icon(&icon, 20., 16., foreground),@@ -340,12 +350,7 @@ impl Workbench {.child(div().ml(px(6.)).text_color(value_color).overflow_hidden().text_ellipsis().child(description.to_owned())),);if let Some(original) = original.cloned() {- let foreground = self.foreground_or("icon.foreground");- let button = self.visualizer_button(&format!("{key}/remove-viz"), Some("eye".into()), "Remove Visualizer".into(), foreground).on_click(cx.listener(move |workbench, _: &ClickEvent, _, cx| {- cx.stop_propagation();- workbench.remove_visualizer(&original, cx);- }));- row = row.child(self.row_action_bar(&group, focused).child(button));+ row = row.child(self.remove_visualizer_action(&key, original, &group, focused, cx));}let can_edit = item["canEdit"] == true;let (row_key, tree) = (key.clone(), tree_id.to_owned());@@ -384,7 +389,7 @@ impl Workbench {cx.notify();}- fn fetch_visualized_children(&mut self, tree_id: &str, item_id: i64, window: &mut Window, cx: &mut Context<Self>) {+ pub(super) fn fetch_visualized_children(&mut self, tree_id: &str, item_id: i64, window: &mut Window, cx: &mut Context<Self>) {if !self.debug.visualizers.trees.contains_key(tree_id) {return;}@@ -572,6 +577,25 @@ mod tests {assert!(!methods(&calls).contains(&"$getVisualizerTreeItem"), "a removed visualizer is no longer preferred");}+ /// watchExpressionsView.ts registers `VisualizedVariableRenderer`: a watch expression's visualized child draws+ /// its tree's item and children.+ #[gpui::test]+ fn a_watch_expressions_visualized_child_draws_its_tree(cx: &mut TestAppContext) {+ let (workbench, cx, host) = visualizer_session(cx);+ answer_calls(&host, cx, tree_answer);+ workbench.update_in(cx, |workbench, window, cx| workbench.use_visualizer(("s".into(), 4, "x".into()), tree_visualizer(), window, cx));+ answer_calls(&host, cx, tree_answer);+ workbench.update_in(cx, |workbench, window, cx| {+ workbench.show_debug_view(cx);+ workbench.debug.model.watch_expressions.push(crate::debug::WatchExpression { id: "w".into(), name: "obj".into() });+ workbench.debug.watch_values.insert("w".into(), Variable { name: "obj".into(), value: "Object".into(), variables_reference: 4, ..Variable::default() });+ workbench.debug_view.expanded.insert("watch/w".into());+ workbench.toggle_visualized_row("watch/w/x", false, TREE, 7, window, cx);+ });+ answer_calls(&host, cx, tree_answer);+ assert!(cx.debug_bounds("watch/w/x/8").is_some(), "the tree's child row draws under the watch expression");+ }+/// `VisualizedVariableRenderer.getInputBoxOptions`: an item that `canEdit` opens with its description, and the/// accepted value goes to `$editVisualizerTreeItem`, whose answer replaces the item.#[gpui::test]diff --git a/port/ledger.md b/port/ledger.mdindex 289927f2566..a161f93f21e 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 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_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; 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 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/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 |