Skip to content

Visual Studio Code, rebuilt in Rust

Rust

feat(debug): show the debug hover for the expression under the mouse

rokartur34243578a146
diff --git a/native/crates/app/src/workbench.rs b/native/crates/app/src/workbench.rs
index 70ccf39050d..56f8c2f1c17 100644
--- a/native/crates/app/src/workbench.rs
+++ b/native/crates/app/src/workbench.rs
@@ -208,6 +208,7 @@ mod color_picker;
mod standalone_color_picker;
mod inlay_hints;
mod debug_inline_values;
+mod debug_hover;
mod rename;
mod links;
mod selection_ranges;
@@ -409,6 +410,7 @@ pub struct Workbench {
code_lenses: code_lens::CodeLenses,
inlay_hints: inlay_hints::InlayHints,
debug_inline_values: debug_inline_values::DebugInlineValues,
+ debug_hover: debug_hover::DebugHover,
color_detector: color_detector::ColorDetector,
inline_completions: inline_completions::InlineCompletions,
language_detection: language_detection::LanguageDetection,
@@ -444,6 +446,7 @@ pub struct Workbench {
status_bar_focus: FocusHandle,
/// contentHoverWidget.ts: the hover's container is focusable (`tabIndex = 0`) inside the editor's DOM node.
content_hover_focus: FocusHandle,
+ debug_hover_focus: FocusHandle,
/// standaloneColorPickerWidget.ts: the standalone color picker's body is focusable (`tabIndex = 0`) inside the editor's DOM node.
standalone_color_picker_focus: FocusHandle,
/// hoverWidget.ts: the workbench hover's container is focusable (`tabIndex = 0`).
@@ -607,6 +610,7 @@ impl Render for Workbench {
self.send_notebook_visible_ranges();
self.render_notebook_cell_lists();
self.follow_content_hover_editor(window, cx);
+ self.follow_debug_hover_editor(window, cx);
self.follow_standalone_color_picker_focus(window, cx);
self.follow_hover_accessible_view(window, cx);
self.follow_rename_editor_state(window, cx);
@@ -783,6 +787,7 @@ impl Workbench {
code_lenses: Default::default(),
inlay_hints: Default::default(),
debug_inline_values: Default::default(),
+ debug_hover: Default::default(),
color_detector: Default::default(),
inline_completions: Default::default(),
language_detection: Default::default(),
@@ -810,6 +815,7 @@ impl Workbench {
banner: banner::Banner::new(cx),
status_bar_focus: cx.focus_handle(),
content_hover_focus: cx.focus_handle(),
+ debug_hover_focus: cx.focus_handle(),
standalone_color_picker_focus: cx.focus_handle(),
workbench_hover_focus: cx.focus_handle(),
tab_focus_toggle: None,
@@ -969,6 +975,7 @@ impl Workbench {
workbench.register_side_by_side_commands();
workbench.register_editor_message_commands();
workbench.register_content_hover_commands();
+ workbench.register_debug_hover_commands();
workbench.register_hover_commands();
workbench.register_suggest();
workbench.register_settings_suggest_commands();
diff --git a/native/crates/app/src/workbench/color_picker.rs b/native/crates/app/src/workbench/color_picker.rs
index d5192b4bede..256599f8d52 100644
--- a/native/crates/app/src/workbench/color_picker.rs
+++ b/native/crates/app/src/workbench/color_picker.rs
@@ -156,7 +156,7 @@ impl Workbench {
if !matches!(activated_on.as_str().unwrap_or("clickAndHover"), "click" | "clickAndHover") {
return;
}
- self.show_content_hover_at(start, super::content_hover::HoverSource::Click, cx);
+ self.show_content_hover_at(start, super::content_hover::HoverSource::Click, false, cx);
}
/// `_isValidRequest`: a mouse hover with `hover` or `clickAndHover`, a click with `click` or `clickAndHover`,
diff --git a/native/crates/app/src/workbench/content_hover.rs b/native/crates/app/src/workbench/content_hover.rs
index 53f3ab59e6a..e8aeae3d9c5 100644
--- a/native/crates/app/src/workbench/content_hover.rs
+++ b/native/crates/app/src/workbench/content_hover.rs
@@ -195,9 +195,9 @@ pub(super) struct Shown {
/// `editor.hover` of the model's language.
pub(super) struct HoverSettings {
- enabled: String,
+ pub(super) enabled: String,
pub(super) delay: u64,
- sticky: bool,
+ pub(super) sticky: bool,
hiding_delay: u64,
pub above: bool,
}
@@ -219,7 +219,8 @@ impl Workbench {
let overrides = Overrides { resource: Some(&resource), override_identifier: Some(&language) };
let value = |key: &str| settings.get_value(Some(&format!("editor.hover.{key}")), &overrides).unwrap_or(Value::Null);
HoverSettings {
- enabled: value("enabled").as_str().unwrap_or("on").to_owned(),
+ // debugEditorContribution.ts `preventDefaultEditorHover` turns the hover off while the debug hover may show.
+ enabled: if self.debug_hover.lockout { "off".to_owned() } else { value("enabled").as_str().unwrap_or("on").to_owned() },
delay: value("delay").as_u64().unwrap_or(300),
sticky: value("sticky").as_bool().unwrap_or(true),
hiding_delay: value("hidingDelay").as_u64().unwrap_or(300),
@@ -689,11 +690,12 @@ impl Workbench {
self.start_showing_or_update_hover(Some(anchor), Mode::Immediate, HoverSource::Keyboard, focus, None, cx);
}
- /// `showContentHover` at `position` with `Immediate` mode (hoverColorPickerContribution.ts on a click).
- pub(super) fn show_content_hover_at(&mut self, position: Position, source: HoverSource, cx: &mut Context<Self>) {
+ /// `showContentHover` at `position` with `Immediate` mode (hoverColorPickerContribution.ts on a click, the debug
+ /// hover's fallback).
+ pub(super) fn show_content_hover_at(&mut self, position: Position, source: HoverSource, focus: bool, cx: &mut Context<Self>) {
let Some(editor) = self.editors.active() else { return };
let anchor = Anchor { model_id: editor.model_id, line: position.line, start: position.column, end: position.column };
- self.start_showing_or_update_hover(Some(anchor), Mode::Immediate, source, false, None, cx);
+ self.start_showing_or_update_hover(Some(anchor), Mode::Immediate, source, focus, None, cx);
}
/// `_startShowingOrUpdateHover`: whether the hover shows or will show for `anchor`.
diff --git a/native/crates/app/src/workbench/debug_hover.rs b/native/crates/app/src/workbench/debug_hover.rs
new file mode 100644
index 00000000000..c19a6c681bf
--- /dev/null
+++ b/native/crates/app/src/workbench/debug_hover.rs
@@ -0,0 +1,608 @@
+//! 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::cell::Cell;
+use std::collections::HashSet;
+use std::rc::Rc;
+use std::sync::LazyLock;
+use std::time::Duration;
+
+use gpui::{
+ Animation, AnimationExt, AnyElement, AsyncWindowContext, Bounds, BoxShadow, ClickEvent, Context, Div, Modifiers, MouseDownEvent, MouseMoveEvent, Point, Size, Task, WeakEntity, Window,
+ canvas, deferred, div, point, prelude::*, px, rgba,
+};
+use regex::Regex;
+use serde_json::json;
+
+use super::Workbench;
+use super::content_hover::{Anchor, HoverSource, MouseTarget, anchor_at};
+use super::debug_service::{answer, on_workbench};
+use crate::debug::session::{State, Variable};
+use crate::editor::{LINE_HEIGHT, OpenEditor, Position, utf16_column};
+use crate::language_features::Candidate;
+
+#[cfg(test)]
+mod tests;
+
+const REGISTER: &str = "$registerEvaluatableExpressionProvider";
+const EDITOR_FONT: &str = "Menlo";
+const EDITOR_FONT_SIZE: f32 = 12.;
+/// debugHover.ts `DebugHoverDelegate.getHeight`.
+const ROW_HEIGHT: f32 = 18.;
+const INDENT: f32 = 8.;
+/// contentWidgets.ts: a widget keeps 22px from the page's top and bottom.
+const PAGE_PADDING: f32 = 22.;
+
+#[derive(Default)]
+pub(super) struct DebugHover {
+ /// `hoverPosition`: the empty anchor under the mouse and the mouse there.
+ position: Option<(Anchor, Point<f32>)>,
+ /// `showHoverScheduler`.
+ scheduled: Option<Task<()>>,
+ /// `showCancellationSource`: the show in flight; dropping it cancels it.
+ showing: Option<Task<()>>,
+ /// DebugHoverComputer `_current`: the expression's range last computed.
+ current: Option<Anchor>,
+ pub(super) shown: Option<ShownValue>,
+ /// `defaultHoverLockout`: the editor hover is off while set.
+ pub(super) lockout: bool,
+ alt_pressed: bool,
+ pub(super) widget_bounds: Rc<Cell<Option<Bounds<f32>>>>,
+ /// The tree's expanded rows by their path; `setInput` starts each value collapsed.
+ expanded: HashSet<String>,
+ focus_on_show: bool,
+ /// Restarts the fade-in of each new value.
+ shows: usize,
+}
+
+pub(super) struct ShownValue {
+ pub range: Anchor,
+ pub session_id: String,
+ pub value: Variable,
+ /// `safeTriangle`'s origin: the mouse that showed it.
+ origin: Option<Point<f32>>,
+ /// `positionPreference` after `afterRender`: where the editor placed the widget, kept while it shows (#109226).
+ above: Cell<Option<bool>>,
+ /// The editor's scroll when shown: `onDidScrollChange` hides it.
+ scroll: (f32, f32),
+}
+
+#[derive(Debug, PartialEq)]
+enum ShowResult {
+ Shown,
+ NotChanged,
+ NotAvailable,
+}
+
+impl Workbench {
+ /// `onEditorMouseMove`: over the text the hover shows for the position after `hoverDelay`, the editor hover off
+ /// meanwhile; over the widget (or on the way to it) a sticky or complex hover stays; elsewhere it hides.
+ pub(super) fn debug_hover_mouse_moved(&mut self, target: MouseTarget, mouse: Point<gpui::Pixels>, modifiers: Modifiers, pressed: bool, window: &mut Window, cx: &mut Context<Self>) {
+ if self.debug.state() != State::Stopped {
+ return;
+ }
+ let mouse = mouse.map(f32::from);
+ let in_triangle = self.in_debug_hover_safe_triangle(mouse);
+ if matches!(target, MouseTarget::Widget) || in_triangle {
+ let sticky = self.editors.active().is_none_or(|editor| self.hover_settings(editor).sticky);
+ let complex = self.debug_hover.shown.as_ref().is_some_and(|shown| shown.value.has_children());
+ if sticky || complex || modifiers.platform {
+ return;
+ }
+ }
+ let text_position = match target {
+ MouseTarget::Text { line, visible } => self.editors.active().and_then(|editor| hover_position(editor, line, visible)),
+ MouseTarget::Widget | MouseTarget::Other => None,
+ };
+ let Some(position) = text_position else {
+ // #64620: a press usually means a selection, which should not close the hover.
+ if !pressed {
+ self.hide_debug_hover_widget(window, cx);
+ }
+ return;
+ };
+ if self.debug_hover.position.is_some_and(|(shown, _)| shown == position) || in_triangle {
+ return;
+ }
+ self.debug_hover.position = Some((position, mouse));
+ self.prevent_default_editor_hover(cx);
+ let delay = self.debug_hover_delay();
+ self.debug_hover.scheduled = Some(cx.spawn_in(window, async move |workbench, cx| {
+ cx.background_executor().timer(delay).await;
+ let _ = workbench.update_in(cx, |workbench, window, cx| {
+ workbench.debug_hover.scheduled = None;
+ if let Some((position, mouse)) = workbench.debug_hover.position
+ && !workbench.debug_hover.alt_pressed
+ {
+ workbench.show_debug_hover(position, false, Some(mouse), window, cx);
+ }
+ });
+ }));
+ }
+
+ /// `onMouseLeave`: leaving the editor for anywhere but the widget hides it.
+ pub(super) fn debug_hover_mouse_left(&mut self, mouse: Point<gpui::Pixels>, window: &mut Window, cx: &mut Context<Self>) {
+ let mouse = mouse.map(f32::from);
+ if self.debug_hover.shown.is_some() && self.debug_hover.widget_bounds.get().is_some_and(|bounds| bounds.contains(&mouse)) {
+ return;
+ }
+ self.hide_debug_hover_widget(window, cx);
+ }
+
+ /// `onEditorMouseDown`: a press anywhere but on the widget hides it.
+ pub(super) fn debug_hover_mouse_down(&mut self, mouse: Point<gpui::Pixels>, window: &mut Window, cx: &mut Context<Self>) {
+ self.debug_hover_mouse_left(mouse, window, cx);
+ }
+
+ /// `onKeyDown`: any key of the editor hides it; Ctrl/Cmd and Alt alone send no key down.
+ pub(super) fn debug_hover_key_down(&mut self, window: &mut Window, cx: &mut Context<Self>) {
+ self.hide_debug_hover_widget(window, cx);
+ }
+
+ /// `applyDocumentListeners`' Alt listener, with the focused frame in the active editor's file: Alt swaps a shown
+ /// debug hover for the editor hover, and its release turns the editor hover off again.
+ pub(super) fn debug_hover_modifiers_changed(&mut self, modifiers: Modifiers, window: &mut Window, cx: &mut Context<Self>) {
+ if modifiers.alt == self.debug_hover.alt_pressed {
+ return;
+ }
+ if !modifiers.alt {
+ self.debug_hover.alt_pressed = false;
+ self.prevent_default_editor_hover(cx);
+ return;
+ }
+ if !self.editors.active().is_some_and(|editor| self.focused_frame_in(editor.model_id)) {
+ return;
+ }
+ self.debug_hover.alt_pressed = true;
+ let was_visible = self.debug_hover.shown.is_some();
+ self.hide_debug_hover(window, cx);
+ self.debug_hover.lockout = false;
+ if was_visible && let Some((position, _)) = self.debug_hover.position {
+ self.show_editor_hover(position, false, cx);
+ }
+ }
+
+ /// `ShowDebugHoverAction` (`editor.debug.action.showDebugHover`): the hover at the cursor, focused.
+ pub(super) fn register_debug_hover_commands(&mut self) {
+ self.commands.register("editor.debug.action.showDebugHover", |workbench, _, window, cx| {
+ if workbench.debug.state() != State::Inactive
+ && let Some(editor) = workbench.editors.active()
+ {
+ let head = editor.selection().head;
+ let position = Anchor { model_id: editor.model_id, line: head.line, start: head.column, end: head.column };
+ workbench.show_debug_hover(position, true, None, window, cx);
+ }
+ crate::commands::Outcome::done()
+ });
+ }
+
+ /// The scroll of the hover's editor moved, it switched models, or the focused frame changed: `hideHoverWidget`.
+ pub(super) fn follow_debug_hover_editor(&mut self, window: &mut Window, cx: &mut Context<Self>) {
+ let Some(shown) = &self.debug_hover.shown else { return };
+ let scroll = self.editors.active().filter(|editor| editor.model_id == shown.range.model_id).map(|editor| (editor.scroll.top, editor.scroll.left));
+ // `onFocusStackFrame`: a frame in another file, or none, hides it.
+ if scroll != Some(shown.scroll) || !self.focused_frame_in(shown.range.model_id) {
+ self.hide_debug_hover_widget(window, cx);
+ }
+ if self.debug_hover.focus_on_show && self.debug_hover.shown.is_some() {
+ self.debug_hover.focus_on_show = false;
+ window.focus(&self.debug_hover_focus, cx);
+ }
+ }
+
+ /// `hideHoverWidget`.
+ pub(super) fn hide_debug_hover_widget(&mut self, window: &mut Window, cx: &mut Context<Self>) {
+ self.hide_debug_hover(window, cx);
+ self.debug_hover.scheduled = None;
+ self.debug_hover.lockout = false;
+ }
+
+ /// `DebugHoverWidget.hide`: a focused widget gives the focus back to the editor.
+ pub(super) fn hide_debug_hover(&mut self, window: &mut Window, cx: &mut Context<Self>) {
+ self.debug_hover.showing = None;
+ if self.debug_hover.shown.take().is_none() {
+ return;
+ }
+ if self.debug_hover_focus.contains_focused(window, cx) {
+ window.focus(&self.editor_focus, cx);
+ }
+ self.debug_hover.widget_bounds.set(None);
+ self.debug_hover.expanded.clear();
+ cx.notify();
+ }
+
+ /// `preventDefaultEditorHover`: the editor hover hides and stays off until the lockout clears.
+ fn prevent_default_editor_hover(&mut self, cx: &mut Context<Self>) {
+ let off = self.editors.active().is_some_and(|editor| self.hover_settings(editor).enabled == "off");
+ if self.debug_hover.lockout || off {
+ return;
+ }
+ self.hide_content_hover(cx);
+ self.debug_hover.lockout = true;
+ }
+
+ /// `showEditorHover`: the lockout clears, else the editor hover would hide at the next mouse move (#193149).
+ fn show_editor_hover(&mut self, position: Anchor, focus: bool, cx: &mut Context<Self>) {
+ self.debug_hover.lockout = false;
+ self.show_content_hover_at(Position::new(position.line, position.start), HoverSource::Mouse, focus, cx);
+ }
+
+ /// `hoverDelay`: `editor.hover.delay` times 2 at 300ms and less, down to times 1 at 900ms and more (#180621).
+ fn debug_hover_delay(&self) -> Duration {
+ let base = self.editors.active().map_or(300, |editor| self.hover_settings(editor).delay) as f64;
+ let factor = (2. - (base - 300.) / 600.).clamp(1., 2.);
+ Duration::from_millis((base * factor) as u64)
+ }
+
+ /// The focused frame's file is the editor's.
+ fn focused_frame_in(&self, model_id: u32) -> bool {
+ let (Some(frame), Some(editor)) = (self.debug.focused_frame(), self.editors.editor_by_id(model_id)) else { return false };
+ let document = editor.document();
+ document.scheme == "file" && frame.path() == Some(&*document.path.to_string_lossy())
+ }
+
+ /// `isInSafeTriangle`: the mouse is between where it showed the hover and the widget.
+ fn in_debug_hover_safe_triangle(&self, mouse: Point<f32>) -> bool {
+ let Some(origin) = self.debug_hover.shown.as_ref().and_then(|shown| shown.origin) else { return false };
+ let Some(bounds) = self.debug_hover.widget_bounds.get() else { return false };
+ in_safe_triangle(origin, bounds, mouse)
+ }
+
+ /// debugEditorContribution.ts `showHover`: the debug hover with the focused frame in the editor's file, else (or
+ /// with nothing to show there) the editor hover.
+ fn show_debug_hover(&mut self, position: Anchor, focus: bool, mouse: Option<Point<f32>>, window: &mut Window, cx: &mut Context<Self>) {
+ self.prevent_default_editor_hover(cx);
+ if !self.focused_frame_in(position.model_id) {
+ self.show_editor_hover(position, focus, cx);
+ return;
+ }
+ self.debug_hover.showing = Some(cx.spawn_in(window, async move |workbench, cx| {
+ let result = show_at(&workbench, cx, position, focus, mouse).await;
+ let _ = on_workbench(&workbench, cx, |workbench, window, cx| {
+ if result == ShowResult::NotAvailable {
+ workbench.hide_debug_hover(window, cx);
+ workbench.show_editor_hover(position, focus, cx);
+ }
+ });
+ }));
+ }
+
+ /// `doShow`: the value, and the children of a complex one, with the range highlighted.
+ fn set_debug_hover_value(&mut self, range: Anchor, session_id: String, value: Variable, focus: bool, mouse: Option<Point<f32>>, window: &mut Window, cx: &mut Context<Self>) {
+ let scroll = self.editors.editor_by_id(range.model_id).map_or((0., 0.), |editor| (editor.scroll.top, editor.scroll.left));
+ if value.has_children() {
+ self.fetch_children(&session_id, value.variables_reference, window, cx);
+ }
+ self.debug_hover.expanded.clear();
+ self.debug_hover.widget_bounds.set(None);
+ self.debug_hover.shows += 1;
+ self.debug_hover.shown = Some(ShownValue { range, session_id, value, origin: mouse, above: Cell::new(None), scroll });
+ self.debug_hover.focus_on_show = focus;
+ cx.notify();
+ }
+
+ /// The `hoverHighlight` decoration of the shown expression's range on model line `index`.
+ pub(super) fn debug_hover_highlight(&self, editor: &OpenEditor, index: usize, char_width: f32) -> Option<Div> {
+ let range = self.debug_hover.shown.as_ref().map(|shown| shown.range).filter(|range| range.model_id == editor.model_id && range.line == index)?;
+ let (left, right) = editor.line_layout(index).range(range.start, range.end);
+ Some(div().absolute().top_0().h_full().left(px(left * char_width)).w(px((right - left) * char_width)).bg(self.color("editor.hoverHighlightBackground")))
+ }
+
+ /// `DebugHoverWidget` as a content widget at the range's start, above the line when it fits, else below.
+ pub(super) fn debug_hover_widget(&self, editor: &OpenEditor, content_left: f32, char_width: f32, window: &Window, cx: &mut Context<Self>) -> Option<AnyElement> {
+ let shown = self.debug_hover.shown.as_ref().filter(|shown| shown.range.model_id == editor.model_id)?;
+ let range = shown.range;
+ if range.line >= editor.document().lines.len() || editor.folding.is_hidden(range.line) {
+ return None;
+ }
+ let view_line = editor.position_view_line(Position::new(range.line, range.start), false);
+ let segment = editor.segment(view_line);
+ // The measuring canvas fills the padding box: add the 1px border on each side.
+ let measured = self.debug_hover.widget_bounds.get().map(|bounds| Size { width: bounds.size.width + 2., height: bounds.size.height + 2. });
+ let size = measured.unwrap_or(Size { width: 0., height: 0. });
+ let editor_bounds = self.text_area_bounds.get();
+ let window_size = window.viewport_size().map(f32::from);
+ let left = editor.segment_pixel_left(segment, range.start, char_width) - editor.scroll.left + content_left;
+ let left = super::editor_message::horizontal_in_page(left, size.width, editor_bounds, window_size);
+ let anchor_top = editor.line_top(view_line, self.editors.viewport) - editor.scroll.top;
+ let fits_above = editor_bounds.origin.y + anchor_top - size.height >= PAGE_PADDING;
+ let fits_below = editor_bounds.origin.y + anchor_top + LINE_HEIGHT + size.height <= window_size.height - PAGE_PADDING;
+ let above = match shown.above.get() {
+ Some(above) => above,
+ None => fits_above || !fits_below,
+ };
+ if measured.is_some() {
+ shown.above.set(Some(above));
+ }
+ // contentWidgets.ts `_layoutBoxInPage` with `fixedOverflowWidgets`: above stays 22px under the page's top.
+ let top = match above {
+ true => (anchor_top - size.height).max(PAGE_PADDING - editor_bounds.origin.y),
+ false => anchor_top + LINE_HEIGHT,
+ };
+ let widget_bounds = self.debug_hover.widget_bounds.clone();
+ let measure = canvas(
+ move |bounds, window, _| {
+ let bounds: Bounds<f32> = bounds.map(f32::from);
+ if widget_bounds.get().map(|old| old.size) != Some(bounds.size) {
+ window.refresh();
+ }
+ widget_bounds.set(Some(bounds));
+ },
+ |_, _, _, _| (),
+ )
+ .absolute()
+ .inset_0();
+ let contents = match shown.value.has_children() {
+ true => self.debug_hover_complex_value(shown, editor_bounds.size.height, cx),
+ false => self.debug_hover_simple_value(&shown.value, editor_bounds.size.width),
+ };
+ let radius = super::content_hover_view::RADIUS;
+ let widget = div()
+ .id("debug-hover")
+ .debug_selector(|| "debug-hover".into())
+ .track_focus(&self.debug_hover_focus)
+ .absolute()
+ .left(px(left))
+ .top(px(top))
+ .border_1()
+ .border_color(self.color("editorHoverWidget.border"))
+ .rounded(px(radius))
+ .bg(self.color("editorHoverWidget.background"))
+ .text_color(self.foreground_or("editorHoverWidget.foreground"))
+ .font_family(EDITOR_FONT)
+ .text_size(px(EDITOR_FONT_SIZE))
+ .cursor_default()
+ .occlude()
+ .when(measured.is_none(), |widget| widget.invisible())
+ // --vscode-shadow-lg.
+ .shadow(vec![BoxShadow { color: rgba(0x00000024).into(), offset: point(px(0.), px(0.)), blur_radius: px(12.), spread_radius: px(0.), inset: false }])
+ .on_mouse_move(cx.listener(|workbench, event: &MouseMoveEvent, window, cx| {
+ workbench.debug_hover_mouse_moved(MouseTarget::Widget, event.position, event.modifiers, event.pressed_button.is_some(), window, cx);
+ }))
+ .on_any_mouse_down(cx.listener(|_, _: &MouseDownEvent, _, cx| cx.stop_propagation()))
+ // The widget is in the editor's DOM: leaving it for outside the editor is the editor's `onMouseLeave`.
+ .on_hover(cx.listener(|workbench, hovered: &bool, window, cx| {
+ if !*hovered && !workbench.text_area_bounds.get().contains(&window.mouse_position().map(f32::from)) {
+ workbench.debug_hover_mouse_left(window.mouse_position(), window, cx);
+ }
+ }))
+ .child(measure)
+ .child(contents)
+ // workbench.css `[tabindex="0"]:focus` on a simple value's container; a complex value focuses the tree, no outline.
+ .when(!shown.value.has_children() && self.debug_hover_focus.is_focused(window), |widget| widget.child(div().absolute().inset_0().rounded(px(radius - 1.)).border_1().border_color(self.color("focusBorder"))))
+ .with_animation(("debug-hover-fade-in", self.debug_hover.shows), Animation::new(Duration::from_millis(150)), |widget, delta| widget.opacity(delta));
+ Some(deferred(widget).with_priority(1).into_any_element())
+ }
+
+ /// `.value`: a value without children, colored by its kind.
+ fn debug_hover_simple_value(&self, value: &Variable, max_width: f32) -> AnyElement {
+ div()
+ .id("debug-hover-value")
+ .max_w(px(max_width))
+ .max_h(px(500.))
+ .overflow_y_scroll()
+ .px(px(5.))
+ .py(px(4.))
+ .line_height(px(LINE_HEIGHT))
+ .text_color(self.value_color(value))
+ .child(value.value.clone())
+ .into_any_element()
+ }
+
+ /// `.complex-value`: the value as the title, its children as a tree, and the Alt tip.
+ fn debug_hover_complex_value(&self, shown: &ShownValue, editor_height: f32, cx: &mut Context<Self>) -> AnyElement {
+ let mut rule = self.color("editorHoverWidget.foreground");
+ (rule.r, rule.g, rule.b, rule.a) = (128. / 255., 128. / 255., 128. / 255., 0.35);
+ let caption = |text: Div| text.h(px(ROW_HEIGHT)).pl(px(15.)).pr(px(2.)).text_size(px(11.)).line_height(px(ROW_HEIGHT)).overflow_hidden().whitespace_nowrap().text_ellipsis();
+ let mut rows = Vec::new();
+ self.debug_hover_rows(&shown.session_id, shown.value.variables_reference, "hover", 0, &mut rows, cx);
+ // shortcut: the tree takes 400 to 550px and up to max(266, 55% of the editor) of height, without layoutTree's
+ // cap that keeps an above hover off the hovered line; needs the tree's content size measured.
+ let tree = div().id("debug-hover-tree").flex().flex_col().max_h(px(266f32.max(editor_height * 0.55))).overflow_y_scroll().cursor_pointer().children(rows);
+ div()
+ .min_w(px(400.))
+ .max_w(px(550.))
+ .flex()
+ .flex_col()
+ .child(caption(div()).border_b_1().border_color(rule).text_color(self.value_color(&shown.value)).child(shown.value.value.clone()))
+ .child(tree)
+ .child(caption(div()).border_t_1().border_color(rule).opacity(0.5).child("Hold Option key to switch to editor language hover"))
+ .into_any_element()
+ }
+
+ /// The tree rows of a reference's children (`VariablesRenderer`), with the expanded ones' children under them.
+ fn debug_hover_rows(&self, session: &str, reference: i64, parent: &str, depth: usize, rows: &mut Vec<AnyElement>, cx: &mut Context<Self>) {
+ let Some(children) = self.debug.children.get(&(session.to_owned(), reference)) else { return };
+ let foreground = self.foreground_or("icon.foreground");
+ for variable in children {
+ let key = format!("{parent}/{}", variable.name);
+ let expandable = variable.has_children();
+ let expanded = expandable && self.debug_hover.expanded.contains(&key);
+ // tree.css `.monaco-tl-twistie`: 16px wide, `padding-right: 6px`, the chevron moved 3px right.
+ let twistie = div().w(px(22.)).pl(px(3.)).pr(px(3.)).flex_none().when(expandable, |twistie| {
+ twistie.child(self.icon(if expanded { "chevron-down" } else { "chevron-right" }, 16., 16., foreground))
+ });
+ let (row_key, session_id, child_reference) = (key.clone(), session.to_owned(), variable.variables_reference);
+ // abstractTree.ts `TreeRenderer.DefaultIndent` (8px) plus `workbench.tree.indent` per level.
+ let indent = 8. + INDENT * depth as f32;
+ let mut row = div().id(gpui::SharedString::from(key.clone())).h(px(ROW_HEIGHT)).flex().items_center().pl(px(indent)).child(twistie).child(self.expression_label(variable));
+ if expandable {
+ row = row.on_click(cx.listener(move |workbench, _: &ClickEvent, window, cx| {
+ if !workbench.debug_hover.expanded.remove(&row_key) {
+ workbench.debug_hover.expanded.insert(row_key.clone());
+ workbench.fetch_children(&session_id, child_reference, window, cx);
+ }
+ cx.notify();
+ }));
+ }
+ rows.push(row.into_any_element());
+ if expanded {
+ self.debug_hover_rows(session, variable.variables_reference, &key, depth + 1, rows, cx);
+ }
+ }
+ }
+}
+
+/// `DebugHoverWidget.showAt`: the expression at `position`, unchanged when its range is the shown one, then its value.
+async fn show_at(workbench: &WeakEntity<Workbench>, cx: &mut AsyncWindowContext, position: Anchor, focus: bool, mouse: Option<Point<f32>>) -> ShowResult {
+ let Ok(Some(session_id)) = on_workbench(workbench, cx, |workbench, _, _| workbench.debug.focus.session.clone()) else { return ShowResult::NotAvailable };
+ let Some((range, expression)) = evaluatable_expression_at(workbench, cx, position).await else { return ShowResult::NotAvailable };
+ let Ok(unchanged) = on_workbench(workbench, cx, |workbench, _, _| {
+ let unchanged = workbench.debug_hover.current == Some(range);
+ workbench.debug_hover.current = Some(range);
+ unchanged && workbench.debug_hover.shown.is_some()
+ }) else {
+ return ShowResult::NotAvailable;
+ };
+ if unchanged {
+ return ShowResult::NotChanged;
+ }
+ let Some(value) = evaluate_hover(workbench, cx, &session_id, range, &expression).await else { return ShowResult::NotAvailable };
+ let _ = on_workbench(workbench, cx, |workbench, window, cx| workbench.set_debug_hover_value(range, session_id, value, focus, mouse, window, cx));
+ ShowResult::Shown
+}
+
+/// debugUtils.ts `getEvaluatableExpressionAtPosition`: the first `EvaluatableExpressionProvider` answer, its text
+/// the range's when it names no expression; without providers, the expression around the position on its line.
+async fn evaluatable_expression_at(workbench: &WeakEntity<Workbench>, cx: &mut AsyncWindowContext, position: Anchor) -> Option<(Anchor, String)> {
+ let calls = on_workbench(workbench, cx, |workbench, _, _| {
+ let editor = workbench.editors.editor_by_id(position.model_id)?;
+ let document = editor.document();
+ let uri = document.uri();
+ let candidate = Candidate { uri: &uri, language: &document.language_id };
+ let column = utf16_column(&document.lines[position.line], position.start) + 1;
+ let at = json!({ "lineNumber": position.line + 1, "column": column });
+ let handles: Vec<u64> = workbench.language_features.ordered(REGISTER, &candidate).iter().map(|registration| registration.handle).collect();
+ Some(handles.into_iter().map(|handle| workbench.host.call_cancellable("ExtHostLanguageFeatures", "$provideEvaluatableExpression", vec![json!(handle), uri.clone(), at.clone()])).collect::<Vec<_>>())
+ })
+ .ok()??;
+ if calls.is_empty() {
+ let line = on_workbench(workbench, cx, |workbench, _, _| workbench.editors.editor_by_id(position.model_id).map(|editor| editor.document().lines[position.line].clone())).ok()??;
+ let (start, end) = exact_expression_start_and_end(&line, position.start + 1, position.start + 1);
+ let expression: String = line.chars().skip(start.max(1) - 1).take((end + 1).saturating_sub(start.max(1))).collect();
+ if start == 0 || expression.is_empty() {
+ return None;
+ }
+ let length = expression.chars().count();
+ return Some((Anchor { start: start - 1, end: start - 1 + length, ..position }, expression));
+ }
+ let mut answers = Vec::new();
+ for call in calls {
+ answers.push(call.await);
+ }
+ let found = answers.into_iter().find_map(|answer| answer.ok()?.ok().filter(|value| value["range"].is_object()))?;
+ on_workbench(workbench, cx, |workbench, _, _| {
+ let editor = workbench.editors.editor_by_id(position.model_id)?;
+ let (start, end) = super::host_requests::range(editor, &found["range"]);
+ let expression = match found["expression"].as_str().filter(|expression| !expression.is_empty()) {
+ Some(expression) => expression.to_owned(),
+ None => editor.document().lines[position.line].chars().skip(start.column).take(end.column.saturating_sub(start.column)).collect(),
+ };
+ let end_column = if end.line == start.line { end.column } else { editor.document().lines[start.line].chars().count() };
+ Some((Anchor { model_id: position.model_id, line: start.line, start: start.column, end: end_column }, expression))
+ })
+ .ok()?
+}
+
+/// DebugHoverComputer `evaluate`: with `supportsEvaluateForHovers` the `hover` evaluation at the range in the focused
+/// frame, else the variable the dotted names reach in its scopes. `None` when it is not available.
+async fn evaluate_hover(workbench: &WeakEntity<Workbench>, cx: &mut AsyncWindowContext, session_id: &str, range: Anchor, expression: &str) -> Option<Variable> {
+ let (frame, for_hovers, column) = on_workbench(workbench, cx, |workbench, _, _| {
+ let frame = workbench.debug.focused_frame()?.clone();
+ let for_hovers = workbench.debug.session(session_id)?.capabilities["supportsEvaluateForHovers"] == true;
+ let line = &workbench.editors.editor_by_id(range.model_id)?.document().lines[range.line];
+ Some((frame, for_hovers, utf16_column(line, range.start) + 1))
+ })
+ .ok()??;
+ if for_hovers {
+ let arguments = json!({ "expression": expression, "frameId": frame.id, "context": "hover", "line": range.line + 1, "column": column, "source": frame.source });
+ let reply = on_workbench(workbench, cx, |workbench, _, _| workbench.dap_request(session_id, "evaluate", arguments)).ok()?;
+ let body = answer(reply).await.ok().filter(|body| !body.is_null())?;
+ return Some(Variable { name: expression.to_owned(), ..Variable::from_dap(&body) });
+ }
+ let names: Vec<&str> = expression.split('.').map(str::trim).filter(|name| !name.is_empty()).collect();
+ find_expression_in_frame(workbench, cx, session_id, frame.id, &names).await
+}
+
+/// debugHover.ts `findExpressionInStackFrame`: in each scope that is not expensive, the variable named by the first
+/// name, then its child named by the next; shown only when every scope that has it has the same value.
+async fn find_expression_in_frame(workbench: &WeakEntity<Workbench>, cx: &mut AsyncWindowContext, session_id: &str, frame_id: i64, names: &[&str]) -> Option<Variable> {
+ let reply = on_workbench(workbench, cx, |workbench, _, _| workbench.dap_request(session_id, "scopes", json!({ "frameId": frame_id }))).ok()?;
+ let scopes = answer(reply).await.ok()?;
+ let mut found: Vec<Variable> = Vec::new();
+ for scope in scopes["scopes"].as_array().into_iter().flatten().filter(|scope| scope["expensive"] != true) {
+ let mut reference = scope["variablesReference"].as_i64().unwrap_or(0);
+ let mut variable = None;
+ for name in names {
+ let reply = on_workbench(workbench, cx, |workbench, _, _| workbench.dap_request(session_id, "variables", json!({ "variablesReference": reference }))).ok()?;
+ let body = answer(reply).await.unwrap_or_default();
+ let children: Vec<Variable> = body["variables"].as_array().into_iter().flatten().map(Variable::from_dap).filter(|child| child.name == *name).collect();
+ variable = match <[Variable; 1]>::try_from(children) {
+ Ok([child]) => Some(child),
+ Err(_) => None,
+ };
+ let Some(child) = &variable else { break };
+ reference = child.variables_reference;
+ }
+ found.extend(variable);
+ }
+ let first = found.first()?;
+ found.iter().all(|variable| variable.value == first.value).then(|| first.clone())
+}
+
+static EXPRESSION: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"(?:[^()\[\]{}<>\s+\-/%~#^;=|,`!]|->)+").expect("a valid pattern"));
+/// JavaScript's `\w` is ASCII.
+static SUB_EXPRESSION: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"(?:[0-9A-Za-z_]|\p{L})+").expect("a valid pattern"));
+
+/// debugUtils.ts `getExactExpressionStartAndEnd`: the 1-based first and last column of the expression around
+/// `loose_start..loose_end` (`a.b.c`, `a?.b`, `a->b`, `A::b`, `...a` as `a`), cut after the word under the end;
+/// `(0, 0)` without one. Columns count chars where JavaScript counts UTF-16 units.
+pub(super) fn exact_expression_start_and_end(line: &str, loose_start: usize, loose_end: usize) -> (usize, usize) {
+ let chars = |bytes: &str| bytes.chars().count();
+ let Some(found) = EXPRESSION.find_iter(line).find(|found| {
+ let start = chars(&line[..found.start()]) + 1;
+ start <= loose_start && start + chars(found.as_str()) >= loose_end
+ }) else {
+ return (0, 0);
+ };
+ let mut start = chars(&line[..found.start()]) + 1;
+ let mut expression = found.as_str();
+ if let Some(spread) = expression.strip_prefix("...").filter(|rest| !rest.is_empty()) {
+ expression = spread;
+ start += 3;
+ }
+ for sub in SUB_EXPRESSION.find_iter(expression) {
+ if chars(&expression[..sub.end()]) + start >= loose_end {
+ expression = &expression[..sub.end()];
+ break;
+ }
+ }
+ (start, start + chars(expression) - 1)
+}
+
+/// mouseTarget.ts `createMouseTargetFromHitTestPosition`'s position on the text: the caret position nearest the
+/// mouse, as the empty anchor there; `None` past the line's end.
+// shortcut: a tab's nearest boundary is taken half a column from the mouse, not half the tab; upgrade when a hover misses after a tab.
+fn hover_position(editor: &OpenEditor, line: usize, visible: f32) -> Option<Anchor> {
+ let under = anchor_at(editor, line, visible)?;
+ let column = anchor_at(editor, line, visible + 0.5).map_or(under.end.max(under.start), |nearest| nearest.start);
+ Some(Anchor { start: column, end: column, ..under })
+}
+
+/// dom.ts `SafeTriangle.contains`: the four triangles from the origin to the widget's corners, in its point order.
+fn in_safe_triangle(origin: Point<f32>, bounds: Bounds<f32>, mouse: Point<f32>) -> bool {
+ let (left, top, right, bottom) = (bounds.origin.x, bounds.origin.y, bounds.origin.x + bounds.size.width, bounds.origin.y + bounds.size.height);
+ let corners = [point(left, top), point(right, top), point(left, bottom), point(right, bottom)];
+ (0..4).any(|index| is_point_within_triangle(mouse, origin, corners[index], corners[(index + 1) % 4]))
+}
+
+/// numbers.ts `isPointWithinTriangle`.
+fn is_point_within_triangle(p: Point<f32>, a: Point<f32>, b: Point<f32>, c: Point<f32>) -> bool {
+ let (v0, v1, v2) = (c - a, b - a, p - a);
+ let dot = |u: Point<f32>, v: Point<f32>| u.x * v.x + u.y * v.y;
+ let (dot00, dot01, dot02, dot11, dot12) = (dot(v0, v0), dot(v0, v1), dot(v0, v2), dot(v1, v1), dot(v1, v2));
+ let inverse = 1. / (dot00 * dot11 - dot01 * dot01);
+ let u = (dot11 * dot02 - dot01 * dot12) * inverse;
+ let v = (dot00 * dot12 - dot01 * dot02) * inverse;
+ u >= 0. && v >= 0. && u + v < 1.
+}
diff --git a/native/crates/app/src/workbench/debug_hover/tests.rs b/native/crates/app/src/workbench/debug_hover/tests.rs
new file mode 100644
index 00000000000..0a673dd6c88
--- /dev/null
+++ b/native/crates/app/src/workbench/debug_hover/tests.rs
@@ -0,0 +1,185 @@
+use std::path::Path;
+use std::sync::mpsc::Receiver;
+use std::sync::{Arc, Mutex};
+
+use exthost::session::ForwardedRequest;
+use gpui::{TestAppContext, VisualTestContext};
+use serde_json::{Value, json};
+
+use super::*;
+use crate::debug::session::StackFrame;
+use crate::host_sync::{HostMessage, HostSync};
+use crate::languages::Languages;
+use crate::workbench::debug_service::DebugFocus;
+
+/// debugUtils.test.ts `getExactExpressionStartAndEnd`.
+#[test]
+fn the_exact_expression_is_the_dotted_path_up_to_the_hovered_word() {
+ let cases: [(&str, usize, usize, (usize, usize)); 17] = [
+ ("foo", 1, 2, (1, 3)),
+ ("!foo", 2, 3, (2, 4)),
+ ("foo", 1, 3, (1, 3)),
+ ("foo", 1, 4, (1, 3)),
+ ("this.name = \"John\"", 1, 10, (1, 9)),
+ ("this.name = \"John\"", 6, 10, (1, 9)),
+ ("this->address = \"Main street\"", 6, 10, (1, 13)),
+ ("var t = a.b.c.d.name", 16, 20, (9, 20)),
+ ("MyClass::StaticProp", 10, 20, (1, 19)),
+ ("largeNumber = myVar?.prop", 21, 25, (15, 25)),
+ ("var t = a.b.c.d.name", 11, 12, (9, 11)),
+ ("var t = a.b;c.d.name", 16, 20, (13, 20)),
+ ("var t = a.b.c-d.name", 16, 20, (15, 20)),
+ ("var aøñéå文 = a.b.c-d.name", 5, 5, (5, 10)),
+ ("aøñéå文.aøñéå文.aøñéå文", 9, 9, (1, 13)),
+ ("[...bar]", 5, 7, (5, 7)),
+ ("...variable", 5, 5, (4, 11)),
+ ];
+ for (line, start, end, expected) in cases {
+ assert_eq!(exact_expression_start_and_end(line, start, end), expected, "{line} {start} {end}");
+ }
+}
+
+#[test]
+fn the_safe_triangle_spans_from_the_mouse_to_the_widget() {
+ let widget = Bounds { origin: point(100., 0.), size: Size { width: 100., height: 50. } };
+ let origin = point(50., 100.);
+ assert!(in_safe_triangle(origin, widget, point(90., 50.)), "between the mouse and the widget");
+ assert!(!in_safe_triangle(origin, widget, point(20., 40.)), "beside the way to the widget");
+}
+
+fn workbench<'a>(cx: &'a mut TestAppContext, file: &Path, capabilities: Value) -> (gpui::Entity<Workbench>, Receiver<HostMessage>, &'a mut VisualTestContext) {
+ let app_root = Path::new(env!("VSCODE_SRC")).to_path_buf();
+ let themes = exthost::scan::scan_extension(&app_root.join("extensions/theme-defaults"), true).unwrap();
+ let javascript = exthost::scan::scan_extension(&app_root.join("extensions/javascript"), true).unwrap();
+ let theme = crate::theme::load_theme(&[themes], "Dark Modern").unwrap();
+ let (sender, host) = std::sync::mpsc::channel();
+ let file = file.to_path_buf();
+ let user = file.parent().unwrap().join("User");
+ let (workbench, cx) = cx.add_window_view(|window, cx| {
+ let mut workbench = Workbench::new(theme, app_root.clone(), None, Languages::new(&[javascript]), Arc::new(Mutex::new(config::service::Settings::load(config::registry::Registry::with_extensions(&[]), user, None))), HostSync::new(sender), cx);
+ workbench.open_file(file.clone(), true, window, cx);
+ let mut session = crate::debug::session::Session::new("s".into(), 1, json!({ "name": "s", "type": "node", "request": "launch" }), json!({}), None, json!({}));
+ session.capabilities = capabilities;
+ session.set_threads(&[json!({ "id": 1, "name": "main" })]);
+ let frame = StackFrame { id: 9, name: "f".into(), source: json!({ "path": file.to_string_lossy() }), line: 2, column: 3, end_line: 2, end_column: 3, ..Default::default() };
+ session.thread_mut(1).unwrap().frames = vec![frame];
+ workbench.debug.sessions.push(session);
+ workbench.set_debug_focus(DebugFocus { session: Some("s".into()), thread: Some(1), frame: Some(9) }, false, window, cx);
+ workbench
+ });
+ cx.run_until_parked();
+ host.try_iter().for_each(drop);
+ (workbench, host, cx)
+}
+
+/// The adapter requests sent so far, each answered by its command's body; the rest stay unanswered.
+fn respond(workbench: &gpui::Entity<Workbench>, host: &Receiver<HostMessage>, bodies: &[(&str, Value)], cx: &mut VisualTestContext) -> Vec<Value> {
+ let requests: Vec<Value> = host.try_iter().filter(|message| message.method == "$sendDAMessage").map(|message| message.args[1].clone()).collect();
+ for request in &requests {
+ 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)));
+ cx.run_until_parked();
+ }
+ requests
+}
+
+fn shown(workbench: &gpui::Entity<Workbench>, cx: &mut VisualTestContext) -> Option<(Anchor, String, i64)> {
+ workbench.read_with(cx, |workbench, _| workbench.debug_hover.shown.as_ref().map(|shown| (shown.range, shown.value.value.clone(), shown.value.variables_reference)))
+}
+
+fn temp_file(name: &str, text: &str) -> std::path::PathBuf {
+ let dir = std::env::temp_dir().join(format!("vsrustium-debug-hover-{name}-{}", std::process::id()));
+ std::fs::create_dir_all(&dir).unwrap();
+ let file = dir.join("a.js");
+ std::fs::write(&file, text).unwrap();
+ file
+}
+
+/// ShowDebugHoverAction at the cursor on `b` of `obj.b.c`: the `hover` evaluation of `obj.b` in the focused frame,
+/// its value with the children of the result, and the editor hover off until the debug hover hides.
+#[gpui::test]
+fn show_debug_hover_evaluates_the_expression_at_the_cursor(cx: &mut TestAppContext) {
+ let file = temp_file("evaluate", "function f(obj) {\n return obj.b.c;\n}\n");
+ let (workbench, host, cx) = workbench(cx, &file, json!({ "supportsEvaluateForHovers": true }));
+ workbench.update_in(cx, |workbench, window, cx| {
+ workbench.editors.active_mut().unwrap().set_selections(vec![crate::editor::Selection::caret(Position::new(1, 14))]);
+ drop(workbench.execute_command("editor.debug.action.showDebugHover", Vec::new(), window, cx));
+ });
+ cx.run_until_parked();
+ let requests = respond(&workbench, &host, &[("evaluate", json!({ "result": "Object", "variablesReference": 7 }))], cx);
+ let evaluate = requests.iter().find(|request| request["command"] == "evaluate").expect("an evaluate request");
+ assert_eq!(evaluate["arguments"]["expression"], "obj.b");
+ assert_eq!(evaluate["arguments"]["context"], "hover");
+ assert_eq!(evaluate["arguments"]["frameId"], 9);
+ assert_eq!((evaluate["arguments"]["line"].clone(), evaluate["arguments"]["column"].clone()), (json!(2), json!(10)));
+ let (range, value, reference) = shown(&workbench, cx).expect("the debug hover shows");
+ assert_eq!((range.line, range.start, range.end, value.as_str(), reference), (1, 9, 14, "Object", 7));
+ let requests = respond(&workbench, &host, &[("variables", json!({ "variables": [{ "name": "c", "value": "3" }] }))], cx);
+ assert!(requests.iter().any(|request| request["command"] == "variables" && request["arguments"]["variablesReference"] == 7), "{requests:?}");
+ let editor_hover = workbench.read_with(cx, |workbench, _| workbench.hover_settings(workbench.editors.active().unwrap()).enabled);
+ assert_eq!(editor_hover, "off");
+
+ workbench.update_in(cx, |workbench, window, cx| workbench.debug_hover_key_down(window, cx));
+ assert!(shown(&workbench, cx).is_none());
+ let editor_hover = workbench.read_with(cx, |workbench, _| workbench.hover_settings(workbench.editors.active().unwrap()).enabled);
+ assert_eq!(editor_hover, "on");
+ std::fs::remove_dir_all(file.parent().unwrap()).unwrap();
+}
+
+/// Without `supportsEvaluateForHovers` the dotted names are looked up in the frame's cheap scopes; a name the
+/// scopes do not have leaves the editor hover to show.
+#[gpui::test]
+fn without_hover_evaluation_the_value_comes_from_the_scopes(cx: &mut TestAppContext) {
+ let file = temp_file("scopes", "function f(obj) {\n return obj.b + missing;\n}\n");
+ let (workbench, host, cx) = workbench(cx, &file, json!({}));
+ let show = |column: usize, workbench: &gpui::Entity<Workbench>, cx: &mut VisualTestContext| {
+ workbench.update_in(cx, |workbench, window, cx| {
+ workbench.editors.active_mut().unwrap().set_selections(vec![crate::editor::Selection::caret(Position::new(1, column))]);
+ drop(workbench.execute_command("editor.debug.action.showDebugHover", Vec::new(), window, cx));
+ });
+ cx.run_until_parked();
+ };
+ show(14, &workbench, cx);
+ respond(&workbench, &host, &[("scopes", json!({ "scopes": [{ "name": "Local", "variablesReference": 4 }, { "name": "Global", "variablesReference": 5, "expensive": true }] }))], cx);
+ respond(&workbench, &host, &[("variables", json!({ "variables": [{ "name": "obj", "value": "Object", "variablesReference": 6 }] }))], cx);
+ let requests = respond(&workbench, &host, &[("variables", json!({ "variables": [{ "name": "b", "value": "2" }] }))], cx);
+ assert_eq!(requests.iter().map(|request| request["arguments"]["variablesReference"].clone()).collect::<Vec<_>>(), [json!(6)], "the expensive scope is skipped");
+ assert_eq!(shown(&workbench, cx).map(|(range, value, _)| (range.start, range.end, value)), Some((9, 14, "2".to_owned())));
+
+ show(20, &workbench, cx);
+ respond(&workbench, &host, &[("scopes", json!({ "scopes": [{ "name": "Local", "variablesReference": 4 }] }))], cx);
+ respond(&workbench, &host, &[("variables", json!({ "variables": [{ "name": "obj", "value": "Object", "variablesReference": 6 }] }))], cx);
+ assert!(shown(&workbench, cx).is_none());
+ assert!(!workbench.read_with(cx, |workbench, _| workbench.debug_hover.lockout), "the editor hover takes over");
+ std::fs::remove_dir_all(file.parent().unwrap()).unwrap();
+}
+
+/// An `EvaluatableExpressionProvider` decides the range; without an expression its text is the range's.
+#[gpui::test]
+fn a_provider_range_without_an_expression_evaluates_the_range_text(cx: &mut TestAppContext) {
+ let file = temp_file("provider", "function f(obj) {\n return obj.b.c;\n}\n");
+ let (workbench, host, cx) = workbench(cx, &file, json!({ "supportsEvaluateForHovers": true }));
+ workbench.update_in(cx, |workbench, window, cx| {
+ workbench.language_features.register(REGISTER, vec![json!(3), json!("*")]);
+ workbench.editors.active_mut().unwrap().set_selections(vec![crate::editor::Selection::caret(Position::new(1, 14))]);
+ drop(workbench.execute_command("editor.debug.action.showDebugHover", Vec::new(), window, cx));
+ });
+ cx.run_until_parked();
+ let range = json!({ "startLineNumber": 2, "startColumn": 10, "endLineNumber": 2, "endColumn": 17 });
+ let mut provided = 0;
+ for mut message in host.try_iter().collect::<Vec<_>>() {
+ if message.method == "$provideEvaluatableExpression" {
+ provided += 1;
+ assert_eq!(message.args[2], json!({ "lineNumber": 2, "column": 15 }));
+ drop(message.reply.take().unwrap().send(Ok(json!({ "range": range }))));
+ }
+ }
+ assert_eq!(provided, 1);
+ cx.run_until_parked();
+ let requests = respond(&workbench, &host, &[("evaluate", json!({ "result": "3", "variablesReference": 0 }))], cx);
+ assert_eq!(requests.iter().map(|request| request["arguments"]["expression"].clone()).collect::<Vec<_>>(), [json!("obj.b.c")]);
+ assert_eq!(shown(&workbench, cx).map(|(range, value, _)| (range.start, range.end, value)), Some((9, 16, "3".to_owned())));
+ std::fs::remove_dir_all(file.parent().unwrap()).unwrap();
+}
diff --git a/native/crates/app/src/workbench/debug_service.rs b/native/crates/app/src/workbench/debug_service.rs
index d5b2a1b7fb0..2768ea272d6 100644
--- a/native/crates/app/src/workbench/debug_service.rs
+++ b/native/crates/app/src/workbench/debug_service.rs
@@ -173,7 +173,7 @@ fn error_message(error: &Value) -> String {
error["message"].as_str().map(str::to_owned).unwrap_or_else(|| error.to_string())
}
-async fn answer(reply: Reply) -> Result<Value, String> {
+pub(super) async fn answer(reply: Reply) -> Result<Value, String> {
match reply.await {
Ok(Ok(value)) => Ok(value),
Ok(Err(error)) => Err(error_message(&error)),
diff --git a/native/crates/app/src/workbench/debug_view.rs b/native/crates/app/src/workbench/debug_view.rs
index bce70c9f043..42bc9ad199f 100644
--- a/native/crates/app/src/workbench/debug_view.rs
+++ b/native/crates/app/src/workbench/debug_view.rs
@@ -362,7 +362,7 @@ impl Workbench {
}
/// debugExpressionRenderer.ts `renderExpressionValue`: numbers, strings and booleans in their token colors.
- fn value_color(&self, variable: &Variable) -> Rgba {
+ pub(super) fn value_color(&self, variable: &Variable) -> Rgba {
let value = variable.value.as_str();
if variable.error {
return self.color("debugTokenExpression.error");
@@ -383,9 +383,15 @@ impl Workbench {
pub(super) fn expression_label(&self, variable: &Variable) -> Div {
let mut label = div().flex().min_w_0().overflow_hidden().whitespace_nowrap();
if !variable.name.is_empty() {
- label = label.child(div().text_color(self.color("debugTokenExpression.name")).child(variable.name.clone())).child(div().child(": ").mr(px(0.)));
+ // debugExpressionRenderer.ts `renderVariable`: the name label is `name =`; debug.contribution.css puts the value 6px after it.
+ let hint = &variable.presentation_hint;
+ let dimmed = hint["kind"] == "virtual" || hint["visibility"] == "internal";
+ label = label.child(div().text_color(self.color("debugTokenExpression.name")).when(dimmed, |name| name.opacity(0.5)).child(match variable.value.is_empty() {
+ true => variable.name.clone(),
+ false => format!("{} =", variable.name),
+ }));
}
- label.child(div().text_color(self.value_color(variable)).overflow_hidden().text_ellipsis().child(variable.value.clone()))
+ label.child(div().when(!variable.name.is_empty(), |value| value.ml(px(6.))).text_color(self.value_color(variable)).overflow_hidden().text_ellipsis().child(variable.value.clone()))
}
fn variables_rows(&self, cx: &mut Context<Self>) -> Vec<gpui::AnyElement> {
diff --git a/native/crates/app/src/workbench/editor_view.rs b/native/crates/app/src/workbench/editor_view.rs
index 0370c2fcc4b..2646d1ee80b 100644
--- a/native/crates/app/src/workbench/editor_view.rs
+++ b/native/crates/app/src/workbench/editor_view.rs
@@ -1124,7 +1124,8 @@ impl Workbench {
}
}))
.on_modifiers_changed(cx.listener(Self::sticky_modifiers_changed))
- .on_modifiers_changed(cx.listener(|workbench, event: &gpui::ModifiersChangedEvent, _, cx| {
+ .on_modifiers_changed(cx.listener(|workbench, event: &gpui::ModifiersChangedEvent, window, cx| {
+ workbench.debug_hover_modifiers_changed(event.modifiers, window, cx);
workbench.text_drag_modifiers_changed(event.modifiers, cx);
workbench.content_hover_modifiers_changed(event.modifiers, cx);
workbench.inline_completions_modifiers_changed(event.modifiers.shift, cx);
@@ -1138,6 +1139,7 @@ impl Workbench {
true => workbench.reveal_scrollbars(cx),
false => {
workbench.hide_scrollbars(cx);
+ workbench.debug_hover_mouse_left(window.mouse_position(), window, cx);
workbench.content_hover_mouse_left(window.mouse_position(), window, cx);
workbench.definition_link_mouse_left();
workbench.commenting_hover_moved(None, cx);
@@ -1152,6 +1154,7 @@ impl Workbench {
Some((line, visible)) => super::content_hover::MouseTarget::Text { line, visible },
None => super::content_hover::MouseTarget::Other,
};
+ workbench.debug_hover_mouse_moved(target, event.position, event.modifiers, event.pressed_button.is_some(), window, cx);
workbench.content_hover_mouse_moved(target, event.position, event.modifiers, event.pressed_button.is_some(), window, cx);
}))
.capture_any_mouse_down(cx.listener(move |workbench, event: &MouseDownEvent, window, cx| {
@@ -1159,6 +1162,7 @@ impl Workbench {
workbench.focus_code_editor(id, window, cx);
}
workbench.hide_content_hover(cx);
+ workbench.debug_hover_mouse_down(event.position, window, cx);
if workbench.middle_scroll_mouse_down(event.button == MouseButton::Middle, event.position, cx) {
cx.stop_propagation();
}
@@ -1295,6 +1299,7 @@ impl Workbench {
.children(self.sticky_scroll_widget(editor, metrics, window, cx))
// Messages and the overlay widgets are the focused editor's; the hover is any code editor's.
.children(self.content_hover_widget(editor, metrics.content_left(), metrics.char_width, window, cx))
+ .children(self.debug_hover_widget(editor, metrics.content_left(), metrics.char_width, window, cx))
.when(!inactive, |shifted| {
shifted
.children(self.editor_message_widget(editor, metrics.content_left(), metrics.char_width, window, cx))
@@ -1944,6 +1949,7 @@ impl Workbench {
content = content.child(highlight);
}
content = content.children(self.content_hover_highlight(editor, index, char_width));
+ content = content.children(self.debug_hover_highlight(editor, index, char_width));
content = content.children(self.code_action_highlights(editor, index, char_width));
content = content.children(self.snippet_placeholder_highlights(editor, index, char_width));
content = content.children(self.symbol_highlight(editor, index, char_width));
diff --git a/native/crates/app/src/workbench/keyboard.rs b/native/crates/app/src/workbench/keyboard.rs
index 3abc8e2d053..0aff2422fde 100644
--- a/native/crates/app/src/workbench/keyboard.rs
+++ b/native/crates/app/src/workbench/keyboard.rs
@@ -252,6 +252,10 @@ impl Workbench {
}
if self.editor_focus.is_focused(window) {
self.content_hover_key_down(&resolution, cx);
+ self.debug_hover_key_down(window, cx);
+ }
+ if keystroke.key == "escape" && self.debug_hover_focus.contains_focused(window, cx) {
+ self.hide_debug_hover(window, cx);
}
// contentHoverWidgetWrapper.ts: the widget's own keydown listener hides it on Escape.
if keystroke.key == "escape" && self.content_hover_focused(window) {
diff --git a/port/ledger.md b/port/ledger.md
index 4251ad4e238..594414aa17b 100644
--- a/port/ledger.md
+++ b/port/ledger.md
@@ -475,7 +475,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 | | Done: a reply and an edit form per thread and comment, open together (commentReply.ts per CommentThreadWidget): cargo test -p app two_threads_keep_their_reply_forms_open_together; a zone sized by the drawn comment bodies: cargo test -p app a_wrapped_comment_body_grows_its_zone; next/previous thread and Focus Comment on Current Line focus the thread's comments (`commentFocused`, Up/Down between comments, Escape collapses and selects the range): cargo test -p app the_reached_thread_takes_the_focus. Done in diff editors: glyphs, commenting ranges (asked for every side of every multi diff file), range highlights and zones on both sides of the diff editor and of each multi diff file, the other side aligned by a diagonal fill (workbench/editor_view/diff_editor_view.rs, multi_diff_editor_view.rs, diff_editor.rs `additional_heights`): cargo test -p app diff comment; ui-pair `portComments.openDiff` modified, original and multi. Floating widgets on a diff's original side and on both sides of each multi diff file (comment_thread_floating.rs `FloatingHost`, multi_diff_editor_view.rs `multi_diff_floating_hosts`), with `FloatingWidgetRoom` growing a file below its last line (commentThreadFloatingWidgetRoom.ts, `FileDiff.room`): cargo test -p app floating room multi_diff; ui-pair `portComments.openDiff` original and multi with the floating style. Range decorations (commentThreadRangeDecorator.ts and the floating empty-range line, workbench/comment_thread_widget.rs `comment_range_highlights`): cargo test -p app comment_thread_floating. The floating thread style (`comments.thread.experimental.style: floating`; workbench/comment_thread_floating_layout.rs with commentThreadFloatingWidget.test.ts ported, workbench/comment_thread_floating.rs: placement beside the code or its lines in code order, the outline and connector, title drag, edge resize, double-click reset, the layout kept per thread, wheel to the editor): cargo test -p app comment_thread_floating, ui-pair steps-comment-floating.json (port/results/language-features.md Floating comment threads). Done: the Comments panel (workbench/comments_view.rs: resources, threads with author, relative time, first line, range and replies, the unresolved badge, a markdown preview's images as "Image: {alt}" (cargo test -p app a_markdown_comment_previews_its_first_rendered_block), the filter box with Show Resolved/Unresolved and Sort By, its history in the memento's `filterHistory`, Escape and Cmd+Down while `commentsFilterFocus` (cargo test -p app the_filter_keeps_its_history_and_escape_clears_it; no match highlights, as commentsTreeViewer.ts's renderers ignore the filter data), Collapse/Expand All, row selection and keys; hideIfEmpty; a thread row's `commentsView/commentThread/context` inline actions and context menu with the built-in Reply, which reveals the thread with its zone expanded and reply open: cargo test -p app the_thread_menu_replies_to_the_thread), the gutter glyph that toggles the thread (workbench/editor_view/comment_glyph.rs) and the thread widget (workbench/comment_thread_widget.rs: zone, state colors, head with `comments/commentThread/title` actions and Collapse, markdown comments with `code` spans on no `textCodeBlock.background` (cargo test -p app a_comment_s_code_span_draws_no_code_block_background), reply form with `comments/commentThread/context` buttons and Cmd+Enter), each comment (workbench/comment_node.rs: `comments/comment/title` actions, edit mode with `comments/comment/context` buttons, reactions and their picker), commenting ranges with the add glyph, Add Comment and template threads (workbench/commenting_ranges.rs), the comment commands (workbench/comment_navigation.rs: Collapse/Expand All, Expand Unresolved, Toggle Editor Commenting, Focus Comment on Current Line, Dismiss Comment, next/previous thread, commented range and commenting range, reached at the provider's columns unless it holds the cursor: cargo test -p app a_commenting_range_is_reached_at_its_columns_unless_it_holds_the_cursor) and the comments accessibility help: cargo test -p app comment; ui-pair port/results/language-features.md (Comments, Comment editing and commands); Escape keeps a new template open as the reference does (ui-pair steps-comment-escape-typed.json, cargo test -p app dismissing_a_new_template_keeps_it_open). The reply and edit inputs are code editors (simpleCommentEditor.ts: a `comment`-scheme markdown model, word wrap, no glyph margin, line numbers or folding, `scrollBeyondLastLine` false, 5 to 25 lines by `calculateEditorHeight`) that take the focus with `commentEditorFocused`, Cmd+Enter submits and Escape hides; the host gets the input's document and no text editor (workbench/comment_thread_widget.rs `open_comment_editor`, workbench/editor.rs `comment_editor`): cargo test -p app an_expanded_thread_shows_a_zone_and_replies_run_the_form_actions a_comment_switched_to_editing_runs_the_edit_actions; ui-pair steps-comment-reply-editor.json (reply-empty, reply-lines, reply-grown). Comments panel rows: 4px pane inset, 4px radius and the tree's indent guides as the Problems tree (cargo test -p app rows_sit_in_the_pane_s_inset_with_the_tree_s_indent_and_guides; ui-pair steps-comments.json: chevron, name and thread line at the reference's x and y) |
| workbench/contrib/customEditor | workbench contribution | M17 | ported | [3 M] custom_editors.rs:637: a custom text editor's resource in two groups shares one webview | Opening a custom text editor with `options.selection` reveals it in the panel and leaves the text model's cursor (cargo test -p app a_custom_text_editor_s_navigation_drives_the_outline); A custom document open in another group moves to the active one, or with `supportsMultipleEditorsPerDocument` gets a second editor there (editorResolverService.ts `moveExistingEditorForResource`: cargo test -p app 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); `workbench.editorAssociations` merged as editorResolverService.ts `getAllUserAssociationsForSetting`: the workspace's globs before the default's and user's (cargo test -p app a_workspace_association_wins_over_a_user_one_of_the_same_length); Reopen Editor With puts a closed custom or notebook editor's replacement in its place, pinned (editorGroupView.ts `replaceEditors`: cargo test -p app a_reopened_preview_keeps_its_tab_position); Two default editors for one resource warn once and remember the choice per extension glob (editorResolverService.ts `doHandleConflictingDefaults`: cargo test -p app two_default_editors_for_a_resource_ask_once_which_to_keep); the memento's custom editors until the extensions register (cargo test -p app markdown_editor_files_offer); editor resolution by `workbench.editorAssociations` and contributed selectors (editorResolverService.ts ranks), Reopen Editor With picker (`reopenActiveEditorWith`, `workbench.action.reopenWithEditor`), `_workbench.open`, `_workbench.openWith`; `FIXTURE=custom-editor-tests port/tools/webview-check` 8/8; cargo test -p app custom_editors |
-| workbench/contrib/debug | workbench contribution | M16 | ported | [3 L] Disassembly view: not ported <br> [3 L] extensionHost launch type: not ported <br> [3 L] debug hover: debugHover.ts (`$provideEvaluatableExpression`, evaluate on hover) | ui-pair port/fixtures/debug-node: gutter breakpoint, F5 stops at it, Variables (Local: main), Call Stack with folded deemphasized frames, Breakpoints, Debug Console REPL, toolbar, status bar entry; cargo test -p app debug; Breakpoints header `$(warning)` hint for the debugger's `strings.unverifiedBreakpoints` after breakpointsView.ts's 4s `hintDelayer`, restarted by every breakpoint change (cargo test -p app debug_view; ui-pair port/fixtures/ui-pair/debug/unverified-breakpoints.json with js-debug's unbound math.test.js breakpoint); preLaunchTask, postDebugTask, compound preLaunchTask and the restart tasks through debugTaskRunner.ts's runner with `debug.onTaskErrors`, the remembered task error choice and the slow task notification (cargo test -p app debug_task_runner); Run to Cursor's temporary breakpoint with debugService.ts `runTo`'s 2s verification wait, thread choice from the sessions that verified it, and removal at the next stop or session end (cargo test -p app debug_commands); Debug Console output styled by its SGR sequences with the theme's ANSI colors at contrast 4 (cargo test -p app debug_console debug::ansi); Debug Console filter box (replFilter.ts terms, "Showing N of M" badge, Cmd+F `repl.action.filter`, value and history in workspace storage) and session picker (consoles of the sessions with `hasSeparateRepl`, `mergeWithParent` children in the parent's, selection focuses the session or its stopped child), input history in workspace storage (`debug.repl.history`) (cargo test -p app debug_console); ended sessions stay inactive in the console picker with their output until Clear Console or a start of the same configuration (debugModel.ts `addSession`, repl.ts `sessionsToIgnore`; cargo test -p app an_ended_session_stays_in_the_picker_until_cleared_or_started_again); debugUtils.ts `saveAllBeforeDebugStart` before a start (not for a child session or with `suppressSaveBeforeStart`) and a restart, by `debug.saveBeforeStart` (cargo test -p app a_start_or_restart_saves_the_dirty_editors); triggered breakpoints: debugSession.ts `enableDependentBreakpoints` by `hitBreakpointIds` or the top frame's position sets `sessionsDidTrigger` and sends the files again, continue and the steps wait for it up to 1.5 s (`waitForTriggeredBreakpoints`), a restart clears it (cargo test -p app a_hit_breakpoint_enables_its_dependents); `debug.inlineValues` after the focused frame's lines: the `InlineValuesProvider`s' values (`$provideInlineValues`) or the most specific scopes' variables named on each line, their `formatHoverContent` hover, the 100ms removal on continue (cargo test -p app debug_inline_values); shortcuts in port/notes.md |
+| workbench/contrib/debug | workbench contribution | M16 | ported | [3 L] Disassembly view: not ported <br> [3 L] extensionHost launch type: not ported | ui-pair port/fixtures/debug-node: gutter breakpoint, F5 stops at it, Variables (Local: main), Call Stack with folded deemphasized frames, Breakpoints, Debug Console REPL, toolbar, status bar entry; cargo test -p app debug; Breakpoints header `$(warning)` hint for the debugger's `strings.unverifiedBreakpoints` after breakpointsView.ts's 4s `hintDelayer`, restarted by every breakpoint change (cargo test -p app debug_view; ui-pair port/fixtures/ui-pair/debug/unverified-breakpoints.json with js-debug's unbound math.test.js breakpoint); preLaunchTask, postDebugTask, compound preLaunchTask and the restart tasks through debugTaskRunner.ts's runner with `debug.onTaskErrors`, the remembered task error choice and the slow task notification (cargo test -p app debug_task_runner); Run to Cursor's temporary breakpoint with debugService.ts `runTo`'s 2s verification wait, thread choice from the sessions that verified it, and removal at the next stop or session end (cargo test -p app debug_commands); Debug Console output styled by its SGR sequences with the theme's ANSI colors at contrast 4 (cargo test -p app debug_console debug::ansi); Debug Console filter box (replFilter.ts terms, "Showing N of M" badge, Cmd+F `repl.action.filter`, value and history in workspace storage) and session picker (consoles of the sessions with `hasSeparateRepl`, `mergeWithParent` children in the parent's, selection focuses the session or its stopped child), input history in workspace storage (`debug.repl.history`) (cargo test -p app debug_console); ended sessions stay inactive in the console picker with their output until Clear Console or a start of the same configuration (debugModel.ts `addSession`, repl.ts `sessionsToIgnore`; cargo test -p app an_ended_session_stays_in_the_picker_until_cleared_or_started_again); debugUtils.ts `saveAllBeforeDebugStart` before a start (not for a child session or with `suppressSaveBeforeStart`) and a restart, by `debug.saveBeforeStart` (cargo test -p app a_start_or_restart_saves_the_dirty_editors); triggered breakpoints: debugSession.ts `enableDependentBreakpoints` by `hitBreakpointIds` or the top frame's position sets `sessionsDidTrigger` and sends the files again, continue and the steps wait for it up to 1.5 s (`waitForTriggeredBreakpoints`), a restart clears it (cargo test -p app a_hit_breakpoint_enables_its_dependents); `debug.inlineValues` after the focused frame's lines: the `InlineValuesProvider`s' values (`$provideInlineValues`) or the most specific scopes' variables named on each line, their `formatHoverContent` hover, the 100ms removal on continue (cargo test -p app debug_inline_values); debugHover.ts in place of the editor hover while a frame is focused in the file: the `$provideEvaluatableExpression` range or the dotted path under the mouse, `hover` evaluation or the scopes' variable, Cmd+K Cmd+I focused, Alt for the editor hover (cargo test -p app debug_hover; ui-pair port/fixtures/debug-node `greeting` and `numbers` hovers); 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.md
index 793c322b23d..3f5d33872cc 100644
--- a/port/notes.md
+++ b/port/notes.md
@@ -934,6 +934,7 @@ Scope as in the M19 Work row of port/ledger.md.
- Testing (`testing.rs`, `workbench/testing_service.rs`, `testing_view.rs`): MainThreadTesting with the test collection diffs, run profiles, live results (`$runControllerTests`, `$startedExtensionTestRun`, `$applyTestRunUpdates`, `$publishTestResults`), the Testing view (shows once a controller registers), run glyphs in the editor gutter and the Test Results editor. VSBuffer arguments of forwarded requests now reach the workbench as byte arrays (`exthost::session::arg_value`).
- 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. Shortcuts: the tree expands by click only, without keyboard navigation, the `DebugHoverContext` menu, lazy variables or visualizers; the tree height keeps 266px to 55% of the editor without `layoutTree`'s cap above the hovered line; a glyph margin hover does not lift the editor hover lockout; a tab's nearest caret position is half a column from the mouse, not half the tab. 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.
- Checks: `cargo test -p app debug` and `cargo test -p app testing::`; api-tests `MOCHA_GREP="vscode API - debug"`; `port/fixtures/debug-node` (app.js with launch.json, math.test.js) with `port/fixtures/extensions/tests-provider` through `port/tools/ui-pair`.
## Milestone 11 windows: dialogs, lifecycle, hot exit, windows, title bar (in progress)