Skip to content

Visual Studio Code, rebuilt in Rust

Rust

feat(testing): select, colorize and link test result messages

rokarturc064a43496f6
diff --git a/native/crates/app/src/workbench.rs b/native/crates/app/src/workbench.rs
index d509baea658..c94c5e88696 100644
--- a/native/crates/app/src/workbench.rs
+++ b/native/crates/app/src/workbench.rs
@@ -45,6 +45,7 @@ mod disassembly_view;
mod testing_continuous;
mod testing_filter;
mod testing_gutter;
+mod testing_message_colorizer;
mod testing_peek;
mod testing_coverage_view;
mod testing_results;
@@ -421,6 +422,7 @@ pub struct Workbench {
marker_navigation: marker_navigation::MarkerNavigation,
goto_symbol: goto_symbol::GotoSymbol,
definition_link: goto_definition_link::DefinitionLink,
+ markdown_selection: markdown_view::MarkdownSelection,
document_highlights: document_highlights::DocumentHighlights,
document_symbols: document_symbols::DocumentSymbols,
references_peek: references_peek::ReferencesPeek,
@@ -827,6 +829,7 @@ impl Workbench {
marker_navigation: Default::default(),
goto_symbol: Default::default(),
definition_link: Default::default(),
+ markdown_selection: Default::default(),
document_highlights: Default::default(),
document_symbols: Default::default(),
references_peek: references_peek::ReferencesPeek::new(cx),
diff --git a/native/crates/app/src/workbench/comment_node.rs b/native/crates/app/src/workbench/comment_node.rs
index 53ebf48f358..b67b5f701e7 100644
--- a/native/crates/app/src/workbench/comment_node.rs
+++ b/native/crates/app/src/workbench/comment_node.rs
@@ -122,7 +122,7 @@ impl Workbench {
(Value::String(text), false) => div().whitespace_normal().child(text.clone()).into_any_element(),
(markdown, false) => {
let blocks = parse(&MarkdownString::from_value(markdown));
- let style = MarkdownStyle { font_size: 13., line_height: BODY_LINE, foreground, action_handler: None, code_foreground: None, code_background: None };
+ let style = MarkdownStyle { font_size: 13., line_height: BODY_LINE, foreground, action_handler: None, code_foreground: None, code_background: None, selectable: false };
self.markdown_blocks(&format!("comment-{}-{}-{index}", widget.controller, widget.thread), &blocks, style, "", cx).into_any_element()
}
};
diff --git a/native/crates/app/src/workbench/comments_view.rs b/native/crates/app/src/workbench/comments_view.rs
index 0a85d6a3258..733fe285009 100644
--- a/native/crates/app/src/workbench/comments_view.rs
+++ b/native/crates/app/src/workbench/comments_view.rs
@@ -613,7 +613,7 @@ impl Workbench {
}
let blocks = preview_blocks(body);
let hover = plain_text(&blocks);
- let style = MarkdownStyle { font_size: 13., line_height: ROW_HEIGHT, foreground: self.foreground_or("foreground"), action_handler: None, code_foreground: Some(self.color("textPreformat.foreground")), code_background: None };
+ let style = MarkdownStyle { font_size: 13., line_height: ROW_HEIGHT, foreground: self.foreground_or("foreground"), action_handler: None, code_foreground: Some(self.color("textPreformat.foreground")), code_background: None, selectable: false };
let rendered = match blocks.first() {
None => div().into_any_element(),
Some(Block::Heading(_, inline)) => div().child(inline.text.clone()).into_any_element(),
diff --git a/native/crates/app/src/workbench/content_hover_view.rs b/native/crates/app/src/workbench/content_hover_view.rs
index 915428d2381..8e6cb55acff 100644
--- a/native/crates/app/src/workbench/content_hover_view.rs
+++ b/native/crates/app/src/workbench/content_hover_view.rs
@@ -435,7 +435,7 @@ impl Workbench {
/// markdownHoverParticipant.ts `renderMarkdown`: each non-empty markdown string in its own `.hover-contents`.
fn markdown_hover_row(&self, contents: &[Value], index: usize, focused_link: Option<usize>, max_width: f32, model_language: &str, cx: &mut Context<Self>) -> (Div, String) {
- let style = MarkdownStyle { font_size: EDITOR_FONT_SIZE, line_height: LINE_HEIGHT, foreground: self.foreground_or("editorHoverWidget.foreground"), action_handler: None, code_foreground: None, code_background: Some(self.color("textCodeBlock.background")) };
+ let style = MarkdownStyle { font_size: EDITOR_FONT_SIZE, line_height: LINE_HEIGHT, foreground: self.foreground_or("editorHoverWidget.foreground"), action_handler: None, code_foreground: None, code_background: Some(self.color("textCodeBlock.background")), selectable: false };
let mut row = div().min_w_0().flex().flex_col();
let mut texts = Vec::new();
let mut links_before = 0;
diff --git a/native/crates/app/src/workbench/editor_commands.rs b/native/crates/app/src/workbench/editor_commands.rs
index eade6268016..45c881dae63 100644
--- a/native/crates/app/src/workbench/editor_commands.rs
+++ b/native/crates/app/src/workbench/editor_commands.rs
@@ -431,7 +431,15 @@ impl Workbench {
fn copy_to_clipboard(&mut self, cut: bool, window: &mut Window, cx: &mut Context<Self>) -> Outcome {
let Some(editor) = self.editors.active().filter(|_| self.editor_focus.is_focused(window)) else {
let command = if cut { "editor.action.clipboardCutAction" } else { "editor.action.clipboardCopyAction" };
- return self.input_text_command(command, window, cx).unwrap_or(Outcome::done());
+ if let Some(outcome) = self.input_text_command(command, window, cx) {
+ return outcome;
+ }
+ // The browser's copy of the selected markdown text; a cut of it, which cannot be edited, does nothing.
+ let selected = self.markdown_selected_text();
+ if !cut && !selected.is_empty() {
+ cx.write_to_clipboard(gpui::ClipboardItem::new_string(selected));
+ }
+ return Outcome::done();
};
let empty_selection_clipboard = self.editor_bool_setting(editor, "editor.emptySelectionClipboard");
if !empty_selection_clipboard && editor.selection().is_empty() {
diff --git a/native/crates/app/src/workbench/editor_groups.rs b/native/crates/app/src/workbench/editor_groups.rs
index 4f32a2be768..e66b4905c1c 100644
--- a/native/crates/app/src/workbench/editor_groups.rs
+++ b/native/crates/app/src/workbench/editor_groups.rs
@@ -962,13 +962,6 @@ impl Workbench {
// A hitbox, not the bounds: the modal part's overlay over the group takes the mouse and the wheel.
|bounds, window, _| window.insert_hitbox(bounds, gpui::HitboxBehavior::Normal),
move |_, hitbox, window, _| {
- let pressed = workbench.clone();
- let pressed_hitbox = hitbox.clone();
- window.on_mouse_event(move |_: &MouseDownEvent, phase, window, cx| {
- if phase == DispatchPhase::Capture && pressed_hitbox.is_hovered(window) {
- pressed.update(cx, |workbench, cx| workbench.focus_group(group, window, cx));
- }
- });
let moved_hitbox = hitbox.clone();
window.on_mouse_event(move |event: &MouseMoveEvent, phase, window, cx| {
if phase == DispatchPhase::Capture && event.pressed_button.is_none() && moved_hitbox.is_hovered(window) {
@@ -984,7 +977,9 @@ impl Workbench {
});
},
);
- body.child(guard.absolute().inset_0())
+ // Capture listeners run in paint order: the body's, painted before its editors', activates the group before
+ // a frame editor's press takes the focus in it (a guard painted last ran after and dropped that focus).
+ body.capture_any_mouse_down(cx.listener(move |workbench, _: &MouseDownEvent, window, cx| workbench.focus_group(group, window, cx))).child(guard.absolute().inset_0())
}
/// The text area of a group that is not active got its size (see `editor_laid_out`).
diff --git a/native/crates/app/src/workbench/editor_view/text_decorations.rs b/native/crates/app/src/workbench/editor_view/text_decorations.rs
index 305fe706617..43573020e7d 100644
--- a/native/crates/app/src/workbench/editor_view/text_decorations.rs
+++ b/native/crates/app/src/workbench/editor_view/text_decorations.rs
@@ -5,7 +5,7 @@
use std::ops::Range;
-use gpui::{AnyElement, Div, FontStyle, FontWeight, HighlightStyle, Rgba, div, prelude::*, px};
+use gpui::{AnyElement, Div, FontStyle, FontWeight, HighlightStyle, Rgba, UnderlineStyle, div, prelude::*, px};
use super::Workbench;
use crate::editor::decoration_types::{DecorationColor, DecorationStyle, Stroke, TextDecoration};
@@ -21,9 +21,14 @@ impl Workbench {
// findWidget.ts theming: `.findMatch` and `.findMatchInline`.
let find_border = if self.theme.kind.is_high_contrast() { "1px dotted" } else { "1px solid" };
let find_match = serde_json::json!({ "backgroundColor": { "id": "editor.findMatchHighlightBackground" }, "border": find_border, "borderColor": { "id": "editor.findMatchHighlightBorder" }, "color": { "id": "editor.findMatchHighlightForeground" }, "overviewRulerColor": { "id": "editorOverviewRuler.findMatchForeground" }, "overviewRulerLane": 2 });
+ let test_message;
let options = match decoration.key.as_str() {
super::super::references_peek::REFERENCE_DECORATION | super::super::hierarchy_peek::HIERARCHY_DECORATION => &reference,
super::super::output_view::FILTER_MATCH_DECORATION => &find_match,
+ key if key.starts_with(super::super::testing_message_colorizer::PREFIX) => {
+ test_message = super::super::testing_message_colorizer::decoration_options(key);
+ &test_message
+ }
key => self.editors.decoration_types.get(key)?,
};
let dark = !self.theme.kind.is_light();
@@ -137,7 +142,7 @@ impl Workbench {
}
/// The text styles of the decorations on model line `line`, as byte ranges of its tab-expanded text.
- pub(super) fn text_decoration_styles(&self, editor: &OpenEditor, line: usize, tab_size: usize) -> Vec<(Range<usize>, HighlightStyle)> {
+ pub(in crate::workbench) fn text_decoration_styles(&self, editor: &OpenEditor, line: usize, tab_size: usize) -> Vec<(Range<usize>, HighlightStyle)> {
let text = &editor.document().lines[line];
let byte = |column: usize| expand_tabs(&text.chars().take(column).collect::<String>(), tab_size).len();
let mut styles = Vec::new();
@@ -148,6 +153,7 @@ impl Workbench {
font_style: (style.font_style.as_deref() == Some("italic")).then_some(FontStyle::Italic),
font_weight: style.font_weight.as_deref().filter(|weight| *weight == "bold").map(|_| FontWeight::BOLD),
fade_out: style.opacity.map(|opacity| 1. - opacity),
+ underline: style.text_decoration.as_deref().filter(|decoration| decoration.split(' ').any(|value| value == "underline")).map(|_| UnderlineStyle { thickness: px(1.), color: None, wavy: false }),
..Default::default()
};
if highlight == HighlightStyle::default() {
diff --git a/native/crates/app/src/workbench/extension_features.rs b/native/crates/app/src/workbench/extension_features.rs
index 22ae1fae3b3..3d1116d60e2 100644
--- a/native/crates/app/src/workbench/extension_features.rs
+++ b/native/crates/app/src/workbench/extension_features.rs
@@ -527,7 +527,7 @@ const CODE_BACKGROUND: Rgba = Rgba { r: 128. / 255., g: 128. / 255., b: 128. / 2
impl Workbench {
pub(super) fn feature_markdown(&self, id: &str, markdown: &str, cx: &mut Context<Self>) -> Div {
let blocks = crate::markdown::parse(&crate::markdown::MarkdownString { value: markdown, is_trusted: &Value::Bool(false), support_theme_icons: true });
- let style = MarkdownStyle { font_size: 13., line_height: 19.5, foreground: self.foreground_or("foreground"), action_handler: None, code_foreground: None, code_background: None };
+ let style = MarkdownStyle { font_size: 13., line_height: 19.5, foreground: self.foreground_or("foreground"), action_handler: None, code_foreground: None, code_background: None, selectable: false };
self.markdown_blocks(id, &blocks, style, "", cx)
}
diff --git a/native/crates/app/src/workbench/goto_definition_link.rs b/native/crates/app/src/workbench/goto_definition_link.rs
index dc8a0131e57..20d1eb91807 100644
--- a/native/crates/app/src/workbench/goto_definition_link.rs
+++ b/native/crates/app/src/workbench/goto_definition_link.rs
@@ -105,7 +105,15 @@ impl Workbench {
return;
}
let Some(position) = self.link_target(line, visible) else { return };
- self.go_to_definition_at(position, side_by_side, window, cx);
+ match self.in_call_stack_frame() {
+ true => {
+ // The results group's guard keeps moves from a frame until a press activates the group, so the press
+ // links the word `onMove` would have.
+ self.start_find_definition(position, cx);
+ self.open_call_stack_word(side_by_side, window, cx);
+ }
+ false => self.go_to_definition_at(position, side_by_side, window, cx),
+ }
self.reset_definition_link(cx);
}
@@ -155,7 +163,7 @@ impl Workbench {
}
let uri = editor.document().uri();
let candidate = Candidate { uri: &uri, language: &editor.document().language_id };
- if self.language_features.ordered(DEFINITION.register, &candidate).is_empty() {
+ if !self.in_call_stack_frame() && self.language_features.ordered(DEFINITION.register, &candidate).is_empty() {
return None;
}
Some(Position::new(line, column_at_visible(text, visible, tab_size)))
@@ -186,6 +194,12 @@ impl Workbench {
self.definition_link.decoration = None;
let state = (editor.model_id, editor.text_model().version_id, editor.scroll.top, editor.scroll.left);
self.definition_link.state = Some(state);
+ if self.in_call_stack_frame() {
+ // callStackWidget.ts `ClickToLocationContribution.onMove`: the word itself is the link, nothing is looked up.
+ self.definition_link.decoration = Some(LinkDecoration { model_id: state.0, line, columns: word, hover: None });
+ cx.notify();
+ return false;
+ }
let text = &editor.document().lines[line];
let dto = json!({ "lineNumber": line + 1, "column": utf16_column(text, position.column) + 1 });
let request = self.provide_locations(DEFINITION, editor, dto, false, cx);
@@ -197,6 +211,28 @@ impl Workbench {
true
}
+ /// callStackWidget.ts frame editors have only `ClickToLocationContribution` of the editor contributions.
+ fn in_call_stack_frame(&self) -> bool {
+ self.editors.active().is_some_and(|editor| self.call_stack_frame(editor).is_some())
+ }
+
+ /// `ClickToLocationContribution` `onExecute`: the frame's file at the linked word's start, centered when outside
+ /// the viewport, to the side with the side-by-side modifier.
+ fn open_call_stack_word(&mut self, side_by_side: bool, window: &mut Window, cx: &mut Context<Self>) {
+ let Some(decoration) = self.definition_link.decoration.as_ref() else { return };
+ let editor = self.editors.active().expect("the link is in the active editor");
+ let line = decoration.line + 1;
+ let column = utf16_column(&editor.document().lines[decoration.line], decoration.columns.start) + 1;
+ let selection = json!({ "startLineNumber": line, "startColumn": column, "endLineNumber": line, "endColumn": column });
+ let mut options = json!({ "selection": selection, "selectionRevealType": 1 });
+ if side_by_side {
+ options["position"] = json!(super::webview_panels::SIDE_GROUP);
+ }
+ let uri = editor.document().uri();
+ // The frame's model is open, so showing it cannot fail on reading it.
+ let _ = self.try_show_text_document(&uri, &options, window, cx);
+ }
+
pub(super) fn register_definition_link_commands(&mut self) {
self.commands.register("editor.action.showDefinitionPreviewHover", |workbench, _, _, cx| {
workbench.show_definition_preview_hover(cx);
diff --git a/native/crates/app/src/workbench/hover.rs b/native/crates/app/src/workbench/hover.rs
index a82d9e52947..2acc609440d 100644
--- a/native/crates/app/src/workbench/hover.rs
+++ b/native/crates/app/src/workbench/hover.rs
@@ -726,7 +726,7 @@ impl Workbench {
span.focused = true;
}
}
- let style = MarkdownStyle { font_size: FONT_SIZE, line_height: LINE_HEIGHT, foreground: self.foreground_or("editorHoverWidget.foreground"), action_handler: Some(Self::open_hover_link), code_foreground: None, code_background: Some(self.color("textCodeBlock.background")) };
+ let style = MarkdownStyle { font_size: FONT_SIZE, line_height: LINE_HEIGHT, foreground: self.foreground_or("editorHoverWidget.foreground"), action_handler: Some(Self::open_hover_link), code_foreground: None, code_background: Some(self.color("textCodeBlock.background")), selectable: false };
let measured = hover.measured.clone();
let measure = canvas(
move |bounds, window, _| {
diff --git a/native/crates/app/src/workbench/markdown_view.rs b/native/crates/app/src/workbench/markdown_view.rs
index ff15ab728df..27c03e47dd3 100644
--- a/native/crates/app/src/workbench/markdown_view.rs
+++ b/native/crates/app/src/workbench/markdown_view.rs
@@ -1,7 +1,10 @@
//! markdownRenderer.ts and editorMarkdownCodeBlockRenderer.ts from the parsed blocks: paragraphs, headings and
//! lists in the UI font, code blocks tokenized in the editor font, links that open or run their command.
-use gpui::{AnyElement, BorderStyle, Bounds, Context, Div, FontStyle, FontWeight, InteractiveText, IntoElement, ParentElement, Pixels, Rgba, StrikethroughStyle, Styled, StyledText, TextLayout, TextRun, Window, canvas, div, point, px};
+use std::cell::{Cell, RefCell};
+use std::rc::Rc;
+
+use gpui::{AnyElement, BorderStyle, Bounds, Context, Div, FontStyle, FontWeight, InteractiveElement, InteractiveText, IntoElement, MouseButton, MouseDownEvent, MouseMoveEvent, ParentElement, Pixels, Point, Rgba, StrikethroughStyle, Styled, StyledText, TextLayout, TextRun, Window, canvas, div, point, px};
use serde_json::Value;
use super::Workbench;
@@ -24,8 +27,30 @@ pub(super) struct MarkdownStyle {
/// A `code` span's background: `textCodeBlock.background` only in hovers, suggest details and parameter hints
/// (hover.css, suggest.css, parameterHints.css).
pub code_background: Option<Rgba>,
+ /// `userSelect: text`: the text takes the window's one `MarkdownSelection`.
+ pub selectable: bool,
+}
+
+/// The text selection of the selectable markdown, one per window as the browser's: its texts in document order as
+/// last drawn, and the selection's anchor and head as (text, byte offset).
+#[derive(Default)]
+pub(super) struct MarkdownSelection {
+ texts: RefCell<Vec<SelectableText>>,
+ anchor: (usize, usize),
+ head: (usize, usize),
+ selecting: bool,
}
+struct SelectableText {
+ layout: TextLayout,
+ text: String,
+ /// Its bounds as last drawn; none for a text not drawn yet.
+ bounds: Rc<Cell<Option<Bounds<Pixels>>>>,
+ /// What a copy puts between it and the text before it, as Chrome's selection `toString`: nothing inside a
+ /// paragraph drawn word by word, `\n` between a code block's lines, `\n\n` between blocks.
+ /// shortcut: list items take `\n\n` where Chrome's tight `li` gives `\n`, refine when a list message needs it.
+ separator: &'static str,
+}
impl Workbench {
/// The blocks stacked with `p, .code, ul` 8px apart (hoverWidget.css `margin: 8px 0`, none at the ends); a code
/// block without a language takes `model_language` (`editor.getModel().getLanguageId()`).
@@ -46,7 +71,7 @@ impl Workbench {
let size = style.font_size * scale;
div().text_size(px(size)).line_height(px(size * 1.1)).font_weight(FontWeight::BOLD).child(self.markdown_inline(id, inline, MarkdownStyle { font_size: size, line_height: size * 1.1, ..style }, cx))
}
- Block::Code { language, text } => self.markdown_code(language, text, model_language),
+ Block::Code { language, text } => self.markdown_code(language, text, model_language, style.selectable),
Block::List { start, items } => {
let mut list = div().flex().flex_col().pl(px(20.));
for (index, item) in items.iter().enumerate() {
@@ -72,7 +97,7 @@ impl Workbench {
/// `tokenizeToString` of the code in the language its alias names, else the model's, in the editor's font
/// (`applyFontInfo`).
- fn markdown_code(&self, language: &str, text: &str, model_language: &str) -> Div {
+ fn markdown_code(&self, language: &str, text: &str, model_language: &str, selectable: bool) -> Div {
let language = match language {
"" => model_language.to_owned(),
alias => self.language_by_name(alias).unwrap_or_else(|| "plaintext".to_owned()),
@@ -82,8 +107,12 @@ impl Workbench {
let line_height = crate::editor::LINE_HEIGHT;
let mut code = div().flex().flex_col().font_family(EDITOR_FONT).text_size(px(EDITOR_FONT_SIZE)).line_height(px(line_height));
for index in 0..lines.len() {
+ let separator = if index == 0 { "\n\n" } else { "\n" };
let runs = tokens.token_styles(&self.theme, &lines, index, 4);
- code = code.child(div().min_h(px(line_height)).child(StyledText::new(crate::editor::expand_tabs(&lines[index], 4)).with_highlights(runs)));
+ let content = crate::editor::expand_tabs(&lines[index], 4);
+ let line = StyledText::new(content.clone()).with_highlights(runs);
+ let selection = selectable.then(|| self.selectable_text(line.layout(), &content, separator));
+ code = code.child(div().relative().min_h(px(line_height)).children(selection).child(line));
}
div().child(code)
}
@@ -101,7 +130,7 @@ impl Workbench {
/// so the row wraps between words as the browser's inline flow does.
pub(super) fn markdown_inline(&self, id: &str, inline: &Inline, style: MarkdownStyle, cx: &mut Context<Self>) -> gpui::AnyElement {
if inline.icons.is_empty() {
- return self.markdown_text(id, inline, style, cx).into_any_element();
+ return self.markdown_text(id, inline, style, false, cx).into_any_element();
}
let mut row = div().flex().flex_wrap().items_center();
let mut icons = inline.icons.iter().peekable();
@@ -109,19 +138,19 @@ impl Workbench {
for (index, char) in inline.text.char_indices() {
let icon_here = icons.peek().is_some_and(|(at, _)| *at == index);
if icon_here && index > start {
- row = row.child(self.markdown_text(&format!("{id}-{start}"), &inline_slice(inline, start..index), style, cx));
+ row = row.child(self.markdown_text(&format!("{id}-{start}"), &inline_slice(inline, start..index), style, start > 0, cx));
start = index;
}
while let Some((_, icon)) = icons.next_if(|(at, _)| *at == index) {
row = row.child(self.icon(icon, 16., 16., style.foreground));
}
if char == ' ' {
- row = row.child(self.markdown_text(&format!("{id}-{start}"), &inline_slice(inline, start..index + 1), style, cx));
+ row = row.child(self.markdown_text(&format!("{id}-{start}"), &inline_slice(inline, start..index + 1), style, start > 0, cx));
start = index + 1;
}
}
if inline.text.len() > start {
- row = row.child(self.markdown_text(&format!("{id}-{start}"), &inline_slice(inline, start..inline.text.len()), style, cx));
+ row = row.child(self.markdown_text(&format!("{id}-{start}"), &inline_slice(inline, start..inline.text.len()), style, start > 0, cx));
}
for (_, icon) in icons {
row = row.child(self.icon(icon, 16., 16., style.foreground));
@@ -131,7 +160,8 @@ impl Workbench {
/// A paragraph's runs: bold, italic, strikethrough, `code` in the editor font with the style's code colors,
/// links in `textLink.foreground` that open on click, a focused one in a 1px `focusBorder` outline.
- fn markdown_text(&self, id: &str, inline: &Inline, style: MarkdownStyle, cx: &mut Context<Self>) -> AnyElement {
+ /// `joined`: the text goes on in the row of the one before it.
+ fn markdown_text(&self, id: &str, inline: &Inline, style: MarkdownStyle, joined: bool, cx: &mut Context<Self>) -> AnyElement {
let link_color = self.color("textLink.foreground");
let mut runs = Vec::new();
let mut links = Vec::new();
@@ -179,6 +209,7 @@ impl Workbench {
let targets: Vec<String> = links.into_iter().map(|(_, target)| target).collect();
let text = StyledText::new(inline.text.clone()).with_runs(runs);
let layout = text.layout().clone();
+ let selection = style.selectable.then(|| self.selectable_text(&layout, &inline.text, if joined { "" } else { "\n\n" }));
let workbench = cx.entity().downgrade();
let open = style.action_handler.unwrap_or(Workbench::open_markdown_link);
let text = InteractiveText::new(id.to_owned(), text).on_click(ranges, move |index, window, cx| {
@@ -186,12 +217,12 @@ impl Workbench {
let _ = workbench.update(cx, |workbench, cx| open(workbench, &target, window, cx));
});
let focused: Vec<_> = inline.spans.iter().filter(|span| span.focused).map(|span| span.range.clone()).collect();
- if focused.is_empty() {
+ if focused.is_empty() && selection.is_none() {
return text.into_any_element();
}
// `.monaco-hover a:focus`: the outline goes around each row the link wraps to, inside its box.
let focus_border = self.color("focusBorder");
- let outline = canvas(
+ let outline = (!focused.is_empty()).then(|| canvas(
|_, _, _| (),
move |_, _, window, _| {
for range in &focused {
@@ -202,8 +233,144 @@ impl Workbench {
},
)
.absolute()
- .inset_0();
- div().relative().child(text).child(outline).into_any_element()
+ .inset_0());
+ div().relative().children(selection).child(text).children(outline).into_any_element()
+ }
+
+ /// `blocks` with `userSelect: text` (testResultsOutput.ts `MarkdownTestMessagePeek`): a press places the selection,
+ /// two select the word and three the text, a drag or a shift press moves its head, a press elsewhere clears it.
+ pub(super) fn selectable_markdown_blocks(&mut self, id: &str, blocks: &[Block], style: MarkdownStyle, cx: &mut Context<Self>) -> Div {
+ self.markdown_selection.texts.get_mut().clear();
+ let root = self.markdown_blocks(id, blocks, MarkdownStyle { selectable: true, ..style }, "", cx);
+ let workbench = cx.entity();
+ let selecting = self.markdown_selection.selecting;
+ // The drag goes on outside the text, as the browser's.
+ let drag = canvas(
+ |_, _, _| (),
+ move |_, _, window, _| {
+ if !selecting {
+ return;
+ }
+ let moved = workbench.clone();
+ window.on_mouse_event(move |event: &MouseMoveEvent, phase, _, cx| {
+ if phase == gpui::DispatchPhase::Capture && event.pressed_button == Some(MouseButton::Left) {
+ moved.update(cx, |workbench, cx| workbench.move_markdown_selection(event.position, cx));
+ }
+ });
+ let released = workbench.clone();
+ window.on_mouse_event(move |_: &gpui::MouseUpEvent, phase, _, cx| {
+ if phase == gpui::DispatchPhase::Capture {
+ released.update(cx, |workbench, _| workbench.markdown_selection.selecting = false);
+ }
+ });
+ },
+ )
+ .absolute()
+ .size_0();
+ let selector = id.to_owned();
+ root.child(drag)
+ .debug_selector(move || selector.clone())
+ .on_mouse_down(MouseButton::Left, cx.listener(|workbench, event: &MouseDownEvent, window, cx| {
+ // A press on text that cannot be focused takes the focus from the editor, so Copy copies the text.
+ window.blur(cx);
+ workbench.press_markdown_selection(event.position, event.click_count, event.modifiers.shift, cx);
+ }))
+ .on_mouse_down_out(cx.listener(|workbench, _: &MouseDownEvent, _, cx| {
+ let selection = &mut workbench.markdown_selection;
+ if selection.anchor != selection.head {
+ selection.anchor = selection.head;
+ cx.notify();
+ }
+ }))
+ }
+
+ fn press_markdown_selection(&mut self, position: Point<Pixels>, click_count: usize, shift: bool, cx: &mut Context<Self>) {
+ let Some(at) = self.markdown_selection_at(position) else { return };
+ let texts = self.markdown_selection.texts.borrow();
+ let text = &texts[at.0].text;
+ let (anchor, head) = match click_count {
+ 1 if shift => (self.markdown_selection.anchor, at),
+ 1 => (at, at),
+ 2 => {
+ let word = word_at(text, at.1);
+ ((at.0, word.start), (at.0, word.end))
+ }
+ _ => ((at.0, 0), (at.0, text.len())),
+ };
+ drop(texts);
+ let selection = &mut self.markdown_selection;
+ (selection.anchor, selection.head, selection.selecting) = (anchor, head, true);
+ cx.notify();
+ }
+
+ fn move_markdown_selection(&mut self, position: Point<Pixels>, cx: &mut Context<Self>) {
+ let Some(at) = self.markdown_selection_at(position).filter(|at| *at != self.markdown_selection.head) else { return };
+ self.markdown_selection.head = at;
+ cx.notify();
+ }
+
+ /// The text and the character boundary at `position`: the drawn text nearest to it, vertically first.
+ fn markdown_selection_at(&self, position: Point<Pixels>) -> Option<(usize, usize)> {
+ let texts = self.markdown_selection.texts.borrow();
+ let distance = |bounds: Bounds<Pixels>| {
+ let away = |low: Pixels, high: Pixels, at: Pixels| (low - at).max(at - high).max(px(0.));
+ (away(bounds.top(), bounds.bottom(), position.y), away(bounds.left(), bounds.right(), position.x))
+ };
+ let mut nearest: Option<(usize, (Pixels, Pixels))> = None;
+ for (index, text) in texts.iter().enumerate() {
+ let Some(bounds) = text.bounds.get() else { continue };
+ if nearest.is_none_or(|(_, best)| distance(bounds) < best) {
+ nearest = Some((index, distance(bounds)));
+ }
+ }
+ let (index, _) = nearest?;
+ Some((index, closest_index(&texts[index].layout, position)))
+ }
+
+ /// The selected text: the texts of a paragraph drawn word by word run on, blocks go on a new line.
+ pub(super) fn markdown_selected_text(&self) -> String {
+ let (start, end) = self.markdown_selection.ordered();
+ let mut selected = String::new();
+ for (index, text) in self.markdown_selection.texts.borrow().iter().enumerate().take(end.0 + 1).skip(start.0) {
+ let from = if index == start.0 { start.1 } else { 0 };
+ let to = if index == end.0 { end.1 } else { text.text.len() };
+ if index > start.0 {
+ selected.push_str(text.separator);
+ }
+ selected.push_str(&text.text[from..to]);
+ }
+ selected
+ }
+
+ /// Takes `layout` into the selection as its next text, and paints the selection's part of it behind it in
+ /// `selection.background`, else Chrome's `::selection` default as measured with the blue accent: #B0D4FB light, #567BA1 dark.
+ fn selectable_text(&self, layout: &TextLayout, text: &str, separator: &'static str) -> gpui::Canvas<()> {
+ let bounds = Rc::new(Cell::new(None));
+ let mut texts = self.markdown_selection.texts.borrow_mut();
+ let index = texts.len();
+ texts.push(SelectableText { layout: layout.clone(), text: text.to_owned(), bounds: bounds.clone(), separator });
+ let (start, end) = self.markdown_selection.ordered();
+ let color = match self.theme.color("selection.background") {
+ Some(_) => self.color("selection.background"),
+ None if self.theme.kind.is_light() => gpui::rgb(0xb0d4fb).into(),
+ None => gpui::rgb(0x567ba1).into(),
+ };
+ let layout = layout.clone();
+ canvas(
+ move |drawn, _, _| bounds.set(Some(drawn)),
+ move |_, _, window, _| {
+ if index < start.0 || index > end.0 {
+ return;
+ }
+ let from = if index == start.0 { start.1 } else { 0 };
+ let to = if index == end.0 { end.1 } else { layout.len() };
+ for row in text_rows(&layout, from..to) {
+ window.paint_quad(gpui::fill(row, color));
+ }
+ },
+ )
+ .absolute()
+ .inset_0()
}
/// `openerService.open` of a rendered link: `command:` runs the command with the JSON arguments of its query,
@@ -254,6 +421,43 @@ fn text_rows(layout: &TextLayout, range: std::ops::Range<usize>) -> Vec<Bounds<P
rows
}
+impl MarkdownSelection {
+ /// The selection's start and end, the anchor or the head first.
+ fn ordered(&self) -> ((usize, usize), (usize, usize)) {
+ (self.anchor.min(self.head), self.anchor.max(self.head))
+ }
+}
+
+/// The character boundary of the drawn text nearest to `position`: on its row, or the row it is level with.
+fn closest_index(layout: &TextLayout, position: Point<Pixels>) -> usize {
+ let line_height = layout.line_height();
+ let mut origin = layout.bounds().origin;
+ let mut start = 0;
+ for line in layout.line_layouts() {
+ let bottom = origin.y + line.size(line_height).height;
+ if position.y < bottom {
+ let within = point(position.x - origin.x, (position.y - origin.y).max(px(0.)));
+ return start + line.closest_index_for_position(within, line_height).unwrap_or_else(|index| index);
+ }
+ origin.y = bottom;
+ start += line.len() + 1;
+ }
+ layout.len()
+}
+
+/// The word around the boundary `at` for a double click: a run of letters, digits and `_`, else the character there.
+fn word_at(text: &str, at: usize) -> std::ops::Range<usize> {
+ let is_word = |c: char| c.is_alphanumeric() || c == '_';
+ let Some(here) = text[at..].chars().next().or_else(|| text[..at].chars().next_back()) else { return at..at };
+ if !is_word(here) {
+ let start = if at == text.len() { at - here.len_utf8() } else { at };
+ return start..start + here.len_utf8();
+ }
+ let start = text[..at].char_indices().rev().take_while(|(_, c)| is_word(*c)).last().map_or(at, |(index, _)| index);
+ let end = text[at..].char_indices().find(|(_, c)| !is_word(*c)).map_or(text.len(), |(index, _)| at + index);
+ start..end
+}
+
/// The text and spans of `inline` within `range`, shifted to start at 0.
fn inline_slice(inline: &Inline, range: std::ops::Range<usize>) -> Inline {
let mut spans = Vec::new();
diff --git a/native/crates/app/src/workbench/parameter_hints.rs b/native/crates/app/src/workbench/parameter_hints.rs
index 721f9e18b16..9c6a8e8c954 100644
--- a/native/crates/app/src/workbench/parameter_hints.rs
+++ b/native/crates/app/src/workbench/parameter_hints.rs
@@ -349,7 +349,7 @@ impl Workbench {
.child(label[end..].to_string())
}
};
- let style = MarkdownStyle { font_size: EDITOR_FONT_SIZE, line_height: LINE_HEIGHT, foreground: self.foreground_or("editorHoverWidget.foreground"), action_handler: None, code_foreground: None, code_background: Some(self.color("textCodeBlock.background")) };
+ let style = MarkdownStyle { font_size: EDITOR_FONT_SIZE, line_height: LINE_HEIGHT, foreground: self.foreground_or("editorHoverWidget.foreground"), action_handler: None, code_foreground: None, code_background: Some(self.color("textCodeBlock.background")), selectable: false };
let language = &editor.document().language_id;
let mut docs = Vec::new();
if let Some(documentation) = active_parameter.map(|parameter| &parameter["documentation"]).filter(|documentation| has_text(documentation)) {
diff --git a/native/crates/app/src/workbench/suggest_widget.rs b/native/crates/app/src/workbench/suggest_widget.rs
index bcef1ae54c6..ef12f6827ce 100644
--- a/native/crates/app/src/workbench/suggest_widget.rs
+++ b/native/crates/app/src/workbench/suggest_widget.rs
@@ -565,7 +565,7 @@ impl Workbench {
let docs = match &item.documentation {
Value::String(text) => Some(div().px(px(5.)).py(px(4.)).when(detail.is_none(), |docs| docs.mr(px(24.))).whitespace_normal().child(text.clone())),
Value::Object(_) => {
- let style = super::markdown_view::MarkdownStyle { font_size: EDITOR_FONT_SIZE, line_height: LINE_HEIGHT, foreground: self.foreground_or("editorSuggestWidget.foreground"), action_handler: None, code_foreground: None, code_background: Some(self.color("textCodeBlock.background")) };
+ let style = super::markdown_view::MarkdownStyle { font_size: EDITOR_FONT_SIZE, line_height: LINE_HEIGHT, foreground: self.foreground_or("editorSuggestWidget.foreground"), action_handler: None, code_foreground: None, code_background: Some(self.color("textCodeBlock.background")), selectable: false };
let blocks = crate::markdown::parse(&crate::markdown::MarkdownString::from_value(&item.documentation));
Some(div().px(px(5.)).py(px(4.)).child(self.markdown_blocks("suggest-details", &blocks, style, &editor.document().language_id, cx)))
}
diff --git a/native/crates/app/src/workbench/testing_message_colorizer.rs b/native/crates/app/src/workbench/testing_message_colorizer.rs
new file mode 100644
index 00000000000..560341a30b6
--- /dev/null
+++ b/native/crates/app/src/workbench/testing_message_colorizer.rs
@@ -0,0 +1,134 @@
+//! testMessageColorizer.ts: a plain text test message's ANSI styles as decorations over its text, with the
+//! control sequences stripped from the text the editor shows (strings.ts `forAnsiStringParts`).
+
+use std::sync::LazyLock;
+
+use regex::Regex;
+use serde_json::{Value, json};
+
+use crate::editor::Position;
+use crate::editor::decoration_types::TextDecoration;
+
+/// `Classes.Prefix`: a decoration's key is its classes joined by spaces, as its `inlineClassName`.
+pub(super) const PREFIX: &str = "tstm-ansidec-";
+
+/// strings.ts `CONTROL_SEQUENCES`: CSI, OSC and ESC sequences.
+static CONTROL_SEQUENCES: LazyLock<Regex> = LazyLock::new(|| {
+ Regex::new(r#"(?:(?:\x1b\[|\x{9b})[=?>!]?[0-9;:]*["$#'* ]?[a-zA-Z@^`{}|~]|(?:\x1b\]|\x{9d}).*?(?:\x1b\\|\x07|\x{9c})|\x1b(?:[ #%\(\)\*\+\-\./]?[a-zA-Z0-9\|}~@]))"#).unwrap()
+});
+
+/// strings.ts `forAnsiStringParts`: the text between control sequences, and the sequences, `true` for a sequence.
+fn ansi_string_parts(text: &str) -> Vec<(bool, &str)> {
+ let mut parts = Vec::new();
+ let mut last = 0;
+ for code in CONTROL_SEQUENCES.find_iter(text) {
+ if code.start() != last {
+ parts.push((false, &text[last..code.start()]));
+ }
+ parts.push((true, code.as_str()));
+ last = code.end();
+ }
+ if last != text.len() {
+ parts.push((false, &text[last..]));
+ }
+ parts
+}
+
+/// strings.ts `removeAnsiEscapeCodes`.
+pub(super) fn remove_ansi_escape_codes(text: &str) -> String {
+ ansi_string_parts(text).into_iter().filter(|(code, _)| !code).map(|(_, part)| part).collect()
+}
+
+/// `colorizeTestMessageInEditor`: a decoration per run of text after a `\x1b[<n>m` code, keyed by its classes.
+/// Columns count chars, the port's model columns.
+pub(super) fn colorize_test_message(message: &str) -> Vec<TextDecoration> {
+ let (bold, italic, underline) = (format!("{PREFIX}1"), format!("{PREFIX}3"), format!("{PREFIX}4"));
+ let (foreground, background) = (format!("{PREFIX}fg"), format!("{PREFIX}bg"));
+ let mut decorations = Vec::new();
+ let mut start = Position::new(0, 0);
+ let mut classes: Vec<String> = Vec::new();
+ for (is_code, part) in ansi_string_parts(message) {
+ if is_code {
+ // `colorAttrRe`: one number only, so `\x1b[1;31m` changes nothing.
+ let Some(attr) = part.strip_prefix("\x1b[").and_then(|code| code.strip_suffix('m')).filter(|attr| !attr.is_empty() && attr.bytes().all(|byte| byte.is_ascii_digit())) else { continue };
+ match attr.parse::<u64>().ok() {
+ Some(0) => classes.clear(),
+ Some(22) => classes.retain(|class| *class != bold && *class != italic),
+ Some(23) => classes.retain(|class| *class != italic),
+ Some(24) => classes.retain(|class| *class != underline),
+ Some(30..=39 | 90..=99) => {
+ classes.retain(|class| !class.starts_with(&foreground));
+ classes.push(format!("{foreground}{attr}"));
+ }
+ Some(40..=49 | 100..=109) => {
+ classes.retain(|class| !class.starts_with(&background));
+ classes.push(format!("{background}{attr}"));
+ }
+ _ => classes.push(format!("{PREFIX}{attr}")),
+ }
+ continue;
+ }
+ let mut end = start;
+ for char in part.chars() {
+ if char == '\n' {
+ end = Position::new(end.line + 1, 0);
+ } else {
+ end.column += 1;
+ }
+ }
+ if !classes.is_empty() {
+ decorations.push(TextDecoration { key: classes.join(" "), start, end, render_options: None });
+ }
+ start = end;
+ }
+ decorations
+}
+
+/// testMessageColorizer.css: the render options of a decoration's classes. Only `bg30` to `bg37` and `bg100` to
+/// `bg107` have a rule, so `\x1b[41m` draws no background.
+pub(super) fn decoration_options(key: &str) -> Value {
+ const COLORS: [&str; 8] = ["Black", "Red", "Green", "Yellow", "Blue", "Magenta", "Cyan", "White"];
+ let color = |number: &str, base: usize, bright: usize| -> Option<Value> {
+ let number: usize = number.parse().ok()?;
+ let (prefix, index) = match number {
+ _ if (base..base + 8).contains(&number) => ("ansi", number - base),
+ _ if (bright..bright + 8).contains(&number) => ("ansiBright", number - bright),
+ _ => return None,
+ };
+ Some(json!({ "id": format!("terminal.{prefix}{}", COLORS[index]) }))
+ };
+ let mut options = json!({});
+ for class in key.split(' ').filter_map(|class| class.strip_prefix(PREFIX)) {
+ match class {
+ "1" => options["fontWeight"] = json!("bold"),
+ "2" => options["opacity"] = json!("0.7"),
+ "3" => options["fontStyle"] = json!("italic"),
+ "4" => options["textDecoration"] = json!("underline"),
+ _ => {}
+ }
+ if let Some(color) = class.strip_prefix("fg").and_then(|number| color(number, 30, 90)) {
+ options["color"] = color;
+ }
+ if let Some(color) = class.strip_prefix("bg").and_then(|number| color(number, 30, 100)) {
+ options["backgroundColor"] = color;
+ }
+ }
+ options
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ /// testMessageColorizer.ts: each run after a color code is decorated with the classes in effect, and `0` clears them.
+ #[test]
+ fn ansi_codes_become_decorations_over_the_stripped_text() {
+ let message = "a \x1b[31mred\x1b[1m bold\nnext\x1b[0m plain \x1b[1;32mx\x1b]8;;link\x07y";
+ assert_eq!(remove_ansi_escape_codes(message), "a red bold\nnext plain xy");
+ let decorations: Vec<_> = colorize_test_message(message).into_iter().map(|decoration| (decoration.key, decoration.start, decoration.end)).collect();
+ let red = "tstm-ansidec-fg31".to_owned();
+ assert_eq!(decorations, vec![(red.clone(), Position::new(0, 2), Position::new(0, 5)), (format!("{red} tstm-ansidec-1"), Position::new(0, 5), Position::new(1, 4))]);
+ let options = decoration_options(&format!("{red} tstm-ansidec-1 tstm-ansidec-bg41 tstm-ansidec-bg101"));
+ assert_eq!(options, json!({ "color": { "id": "terminal.ansiRed" }, "fontWeight": "bold", "backgroundColor": { "id": "terminal.ansiBrightRed" } }));
+ }
+}
diff --git a/native/crates/app/src/workbench/testing_results.rs b/native/crates/app/src/workbench/testing_results.rs
index 7f8144cc1c6..e8dce0340d1 100644
--- a/native/crates/app/src/workbench/testing_results.rs
+++ b/native/crates/app/src/workbench/testing_results.rs
@@ -12,6 +12,7 @@ use super::Workbench;
use super::hover::{HoverContent, HoverOptions};
use super::markdown_view::MarkdownStyle;
use super::testing_item_menu::result_state_context;
+use super::testing_message_colorizer;
use super::testing_view::state_icon;
use crate::commands::Outcome;
use crate::diff_editor::{DIFF_EDITOR_SCHEME, DiffInput, Side};
@@ -670,6 +671,7 @@ impl Workbench {
/// testResultsViewContent.ts `reveal`: the subject's content and its call stack.
pub(super) fn show_results_subject(&mut self, subject: InspectSubject) {
self.testing_view.results_subject = Some(subject);
+ self.markdown_selection = Default::default();
self.show_message_editor();
self.show_call_stack();
}
@@ -804,10 +806,12 @@ impl Workbench {
editor.add_view_zone(None, DIFF_LENS_ZONE_HEIGHT);
}
} else {
- let text = super::debug_console::strip_ansi(message_text(&value));
+ let text = testing_message_colorizer::remove_ansi_escape_codes(message_text(&value));
workbench.editors.open(document(workbench, TEST_DATA_SCHEME, MESSAGE_PART, &text), false);
+ let editor = workbench.editors.active_mut().expect("just opened");
+ editor.text_decorations = testing_message_colorizer::colorize_test_message(message_text(&value));
// wordHighlighter.ts runs on an explicit cursor move or the text focus, which a model set here is not.
- workbench.editors.active_mut().expect("just opened").highlights.clear();
+ editor.highlights.clear();
}
if let Some(replaced) = replaced {
let index = workbench.editors.editors.iter().position(|editor| editor.model_id == replaced).expect("not closed yet");
@@ -899,10 +903,11 @@ impl Workbench {
}
/// The Test Results view: the opened subject's text and, by `testing.resultsView.layout`, the tree on its right
- /// or left, each half the width (`Sizing.Distribute`).
+ /// or left. testResultsViewContent.ts adds both with `Sizing.Distribute` to a split view of size 0, which leaves
+ /// them at their minimums, 200 and 100, so its proportional layout splits the width 2:1 down to those minimums.
pub(super) fn test_results_body(&mut self, window: &mut Window, cx: &mut Context<Self>) -> Div {
- let content = self.results_content(window, cx);
- let tree = self.results_tree(window, cx);
+ let content = self.results_content(window, cx).flex_grow(2.).min_w(px(200.)).debug_selector(|| "test-results-content".into());
+ let tree = self.results_tree(window, cx).min_w(px(100.)).debug_selector(|| "test-results-tree".into());
let body = div().flex_1().min_h_0().flex();
match self.setting("testing.resultsView.layout").as_str() {
Some("treeLeft") => body.child(tree).child(content),
@@ -1070,7 +1075,8 @@ impl Workbench {
let message = self.results_subject_view(window, cx);
list = list.child(div().flex_none().flex().when_some(height, |message, height| message.h(px(height))).child(message));
} else if let Some(editor) = row.editor.and_then(|id| self.editors.editor_by_id(id)) {
- list = list.child(div().flex_none().h(px(content_height(editor))).flex().child(self.embedded_code_editor(editor, window, cx)));
+ let frame = div().flex_none().h(px(content_height(editor))).flex().debug_selector(move || format!("test-results-frame-{index}"));
+ list = list.child(frame.child(self.embedded_code_editor(editor, window, cx)));
}
}
list
@@ -1166,12 +1172,12 @@ impl Workbench {
/// The subject: a diffable message in its diff editor, a plain text one in its code editor, else a task's or a
/// test's output as plain lines; a message with testResultsViewContent.ts `populateFloatingClick`'s button.
fn results_subject_view(&mut self, window: &mut Window, cx: &mut Context<Self>) -> gpui::Stateful<Div> {
- if self.message_editor().is_some() {
- let editor = self.editors.active().expect("the message's editor");
+ if let Some(editor) = self.message_editor() {
let body = div().flex_1().min_h_0().flex().flex_col();
+ // A focused frame's code editor is the active one; the message then draws as an unfocused code editor.
let body = match self.editors.active_diff() {
Some(diff) => body.child(self.diff_editor_body(diff, diff.modified_editor.as_ref().unwrap_or(editor), window, cx)),
- None => body.child(self.text_area(editor, window, cx)),
+ None => body.child(self.embedded_code_editor(editor, window, cx)),
};
let floating = self.results_floating_button(window, cx);
return div().id("test-results-output").flex_1().min_w_0().relative().flex().flex_col().child(body).children(floating);
@@ -1185,9 +1191,9 @@ impl Workbench {
if let Some(markdown) = self.markdown_message() {
let blocks = crate::markdown::parse(&markdown);
// `line-height: normal` of the 13px system font.
- let style = MarkdownStyle { font_size: 13., line_height: 15., foreground: self.color("foreground"), action_handler: None, code_foreground: None, code_background: None };
+ let style = MarkdownStyle { font_size: 13., line_height: 15., foreground: self.color("foreground"), action_handler: None, code_foreground: None, code_background: None, selectable: true };
// testing.css `.preview-text`: 8px 12px 8px 20px of padding; paragraphs 1em apart, none at the ends.
- let text = self.markdown_blocks("test-results-markdown", &blocks, style, "", cx).gap(px(13.)).pt(px(8.)).pr(px(12.)).pb(px(8.)).pl(px(20.));
+ let text = self.selectable_markdown_blocks("test-results-markdown", &blocks, style, cx).gap(px(13.)).pt(px(8.)).pr(px(12.)).pb(px(8.)).pl(px(20.));
return div().id("test-results-output").flex_1().min_w_0().relative().overflow_y_scroll().px(px(self.pane_row_inset())).child(text).children(self.results_floating_button(window, cx));
}
let content = div().id("test-results-output").flex_1().min_w_0().relative().overflow_y_scroll().p(px(8.)).font_family("Menlo").text_size(px(12.)).flex().flex_col();
diff --git a/native/crates/app/src/workbench/testing_results/tests.rs b/native/crates/app/src/workbench/testing_results/tests.rs
index 97d82a159d5..7aa79d1b40b 100644
--- a/native/crates/app/src/workbench/testing_results/tests.rs
+++ b/native/crates/app/src/workbench/testing_results/tests.rs
@@ -60,6 +60,39 @@ fn an_opened_plain_text_message_shows_in_a_read_only_code_editor(cx: &mut TestAp
});
}
+/// testResultsViewContent.ts `fillBody`: the content and the tree split the view 2:1, by their split view minimums.
+#[gpui::test]
+fn the_content_and_the_tree_split_the_view_two_to_one(cx: &mut TestAppContext) {
+ let (workbench, cx, _host) = workbench_with_tests("test-results-split", TESTS, cx);
+ workbench.update_in(cx, |workbench, _, cx| {
+ add_results(workbench);
+ workbench.open_panel_view(crate::workbench::testing_view::TEST_RESULTS_VIEW_ID, cx);
+ workbench.open_results_element(&ResultsElement::Message { result: "r1".into(), task: 0, test: "c\0f\0b".into(), message: 0 });
+ });
+ cx.run_until_parked();
+ let (content, tree) = (cx.debug_bounds("test-results-content").expect("drawn"), cx.debug_bounds("test-results-tree").expect("drawn"));
+ assert!(tree.size.width > gpui::px(100.));
+ // The tree's 1px left border is its flex basis, outside the 2:1 split of the rest.
+ assert!((content.size.width - (tree.size.width - gpui::px(1.)) * 2.).abs() <= gpui::px(1.), "{content:?} {tree:?}");
+}
+
+/// testMessageColorizer.ts `colorizeTestMessageInEditor`: a plain text message's ANSI codes leave its text and
+/// color it through decorations, in the terminal's ANSI colors.
+#[gpui::test]
+fn an_opened_plain_text_message_shows_its_ansi_styles(cx: &mut TestAppContext) {
+ let (workbench, cx, _host) = workbench_with_tests("test-results-ansi", TESTS, cx);
+ workbench.update_in(cx, |workbench, _, _| {
+ add_results(workbench);
+ workbench.testing.results[0].append_message("c\0f\0b", "t1", error("got \x1b[31mred\x1b[4m line\x1b[0m end"));
+ workbench.open_results_element(&ResultsElement::Message { result: "r1".into(), task: 0, test: "c\0f\0b".into(), message: 1 });
+ let editor = workbench.message_editor().expect("the message's code editor");
+ assert_eq!(editor.document().lines, vec!["got red line end".to_owned()]);
+ let styles: Vec<_> = workbench.text_decoration_styles(editor, 0, 4).into_iter().map(|(range, style)| (range, style.color, style.underline.is_some())).collect();
+ let red = workbench.theme.color("terminal.ansiRed").map(Into::into);
+ assert_eq!(styles, vec![(4..7, red, false), (7..12, red, true)]);
+ });
+}
+
/// testResultsOutput.ts `TerminalMessagePeek`: a task shows the run's output in a detached terminal, a test its own
/// output, appended as it comes, and a test without output the notice once the run completed.
#[gpui::test]
@@ -108,6 +141,32 @@ fn an_opened_markdown_message_renders_its_markdown(cx: &mut TestAppContext) {
});
}
+/// testResultsOutput.ts `MarkdownTestMessagePeek` sets `userSelect: text`: a drag across a markdown message selects
+/// its text, a double click a word, and Copy copies the selection with Chrome's blank line between paragraphs.
+#[gpui::test]
+fn a_markdown_messages_text_can_be_selected_and_copied(cx: &mut TestAppContext) {
+ let (workbench, cx, _host) = workbench_with_tests("test-results-markdown-select", TESTS, cx);
+ workbench.update_in(cx, |workbench, _, cx| {
+ add_results(workbench);
+ workbench.testing.results[0].append_message("c\0f\0b", "t1", json!({ "type": 0, "message": { "value": "The **sum** failed\n\nsecond", "isTrusted": false }, "expected": null, "actual": null, "contextValue": null, "location": null }));
+ workbench.open_panel_view(crate::workbench::testing_view::TEST_RESULTS_VIEW_ID, cx);
+ workbench.open_results_element(&ResultsElement::Message { result: "r1".into(), task: 0, test: "c\0f\0b".into(), message: 1 });
+ });
+ cx.run_until_parked();
+ let text = cx.debug_bounds("test-results-markdown").expect("drawn");
+ // testing.css `.preview-text` pads the text 20px from the left and 8px from the top; its rows are 15px.
+ let first_row = text.origin + gpui::point(gpui::px(21.), gpui::px(15.));
+ cx.simulate_mouse_down(first_row, gpui::MouseButton::Left, gpui::Modifiers::none());
+ cx.simulate_mouse_move(text.origin + gpui::point(gpui::px(400.), gpui::px(45.)), gpui::MouseButton::Left, gpui::Modifiers::none());
+ cx.simulate_mouse_up(text.origin + gpui::point(gpui::px(400.), gpui::px(45.)), gpui::MouseButton::Left, gpui::Modifiers::none());
+ workbench.read_with(cx, |workbench, _| assert_eq!(workbench.markdown_selected_text(), "The sum failed\n\nsecond"));
+ workbench.update_in(cx, |workbench, window, cx| _ = workbench.execute_command("editor.action.clipboardCopyAction", Vec::new(), window, cx));
+ assert_eq!(cx.read_from_clipboard().and_then(|item| item.text()).as_deref(), Some("The sum failed\n\nsecond"));
+ cx.simulate_event(gpui::MouseDownEvent { button: gpui::MouseButton::Left, position: first_row, modifiers: gpui::Modifiers::none(), click_count: 2, first_mouse: false });
+ cx.simulate_mouse_up(first_row, gpui::MouseButton::Left, gpui::Modifiers::none());
+ workbench.read_with(cx, |workbench, _| assert_eq!(workbench.markdown_selected_text(), "The"));
+}
+
/// testResultsViewContent.ts `setCallStackFrames` and callStackWidget.ts: a message's stack trace lists after it, a
/// frame with a source as a read-only editor of its line and 2 around it, the line highlighted and its column marked,
/// one without as its label and location; another message drops the frames' editors.
@@ -146,6 +205,63 @@ fn an_opened_message_with_a_stack_trace_lists_its_frames(cx: &mut TestAppContext
assert!(workbench.editors.editor_by_id(frame).is_none(), "the frame's editor went with its message");
});
}
+
+/// callStackWidget.ts renders each frame in its own list row: a press that focuses a frame's code editor leaves the
+/// message's row showing the message.
+#[gpui::test]
+fn a_press_in_a_frame_leaves_the_message_shown(cx: &mut TestAppContext) {
+ let (workbench, cx, _host) = workbench_with_tests("test-results-stack-press", TESTS, cx);
+ let source = std::env::temp_dir().join(format!("code-gpui-test-results-stack-press-{}", std::process::id())).join("stack.test.js");
+ std::fs::create_dir_all(source.parent().unwrap()).unwrap();
+ std::fs::write(&source, (1..=12).map(|line| format!("line {line}\n")).collect::<String>()).unwrap();
+ let message = workbench.update_in(cx, |workbench, _, cx| {
+ add_results(workbench);
+ let frames = json!([{ "label": "sum", "uri": { "scheme": "file", "path": source.to_string_lossy() }, "position": { "lineNumber": 7, "column": 3 } }]);
+ workbench.testing.results[0].append_message("c\0f\0b", "t1", json!({ "type": 0, "message": "sum failed", "expected": null, "actual": null, "contextValue": null, "location": null, "stackTrace": frames }));
+ workbench.open_panel_view(crate::workbench::testing_view::TEST_RESULTS_VIEW_ID, cx);
+ workbench.open_results_element(&ResultsElement::Message { result: "r1".into(), task: 0, test: "c\0f\0b".into(), message: 1 });
+ workbench.message_editor().expect("the message's editor").model_id
+ });
+ cx.run_until_parked();
+ let frame = cx.debug_bounds("test-results-frame-1").expect("the frame's code editor is drawn");
+ cx.simulate_click(frame.center(), gpui::Modifiers::default());
+ cx.run_until_parked();
+ assert!(cx.debug_bounds(format!("text-area-{message}").leak()).is_some(), "the message's text area is drawn");
+ std::fs::remove_dir_all(source.parent().unwrap()).unwrap();
+}
+
+/// callStackWidget.ts `ClickToLocationContribution`: in a frame's code editor, the word under the mouse with Cmd held
+/// is a link without a definition provider, and Cmd+click opens the frame's file at the word's start.
+#[gpui::test]
+fn cmd_click_on_a_word_in_a_frame_opens_its_file_there(cx: &mut TestAppContext) {
+ let (workbench, cx, _host) = workbench_with_tests("test-results-stack-click", TESTS, cx);
+ let source = std::env::temp_dir().join(format!("code-gpui-test-results-stack-click-{}", std::process::id())).join("stack.test.js");
+ std::fs::create_dir_all(source.parent().unwrap()).unwrap();
+ std::fs::write(&source, (1..=12).map(|line| format!("line {line}\n")).collect::<String>()).unwrap();
+ let cmd = gpui::Modifiers { platform: true, ..Default::default() };
+ workbench.update_in(cx, |workbench, _, cx| {
+ add_results(workbench);
+ let frames = json!([{ "label": "sum", "uri": { "scheme": "file", "path": source.to_string_lossy() }, "position": { "lineNumber": 7, "column": 3 } }]);
+ workbench.testing.results[0].append_message("c\0f\0b", "t1", json!({ "type": 0, "message": "sum failed", "expected": null, "actual": null, "contextValue": null, "location": null, "stackTrace": frames }));
+ workbench.open_panel_view(crate::workbench::testing_view::TEST_RESULTS_VIEW_ID, cx);
+ workbench.open_results_element(&ResultsElement::Message { result: "r1".into(), task: 0, test: "c\0f\0b".into(), message: 1 });
+ });
+ cx.run_until_parked();
+ // The frame shows lines 5 to 9; "line 7", the third, starts past the 5-column line numbers.
+ let frame = cx.debug_bounds("test-results-frame-1").expect("the frame's code editor is drawn");
+ let word = frame.origin + gpui::point(gpui::px(80.), gpui::px(crate::editor::LINE_HEIGHT * 2.5));
+ cx.simulate_mouse_move(word, None, cmd);
+ cx.simulate_mouse_down(word, gpui::MouseButton::Left, cmd);
+ cx.simulate_mouse_up(word, gpui::MouseButton::Left, cmd);
+ cx.run_until_parked();
+ workbench.read_with(cx, |workbench, _| {
+ assert_ne!(workbench.editors.id, crate::editor::TEST_RESULTS_GROUP);
+ let editor = workbench.editors.active().expect("the frame's file");
+ assert_eq!(editor.document().path, source);
+ assert_eq!(editor.selection().head.line, 6);
+ });
+ std::fs::remove_dir_all(source.parent().unwrap()).unwrap();
+}
/// testResultsOutput.ts `DiffContentProvider`: an opened diffable message shows its expected and actual models side by
/// side in an embedded diff editor, with line numbers when a side is multiline; a plain text message replaces it.
#[gpui::test]
diff --git a/native/crates/app/src/workbench/tree_view.rs b/native/crates/app/src/workbench/tree_view.rs
index ff22b21ec3d..c38777d928c 100644
--- a/native/crates/app/src/workbench/tree_view.rs
+++ b/native/crates/app/src/workbench/tree_view.rs
@@ -575,7 +575,7 @@ impl Workbench {
}
let markdown = MarkdownString::from_value(message);
let enablements = crate::keybindings::command_enablements(&self.extensions);
- let style = MarkdownStyle { font_size: 13., line_height: 18.2, foreground: self.foreground_or("sideBar.foreground"), action_handler: None, code_foreground: None, code_background: None };
+ let style = MarkdownStyle { font_size: 13., line_height: 18.2, foreground: self.foreground_or("sideBar.foreground"), action_handler: None, code_foreground: None, code_background: None, selectable: false };
let lines = message_lines(markdown.value);
let count = lines.len();
let mut rendered = div().w_full().flex().flex_col();
diff --git a/port/fixtures/extensions/tests-provider/extension.js b/port/fixtures/extensions/tests-provider/extension.js
index 4b82163647d..9dc39235047 100644
--- a/port/fixtures/extensions/tests-provider/extension.js
+++ b/port/fixtures/extensions/tests-provider/extension.js
@@ -1,6 +1,6 @@
// Each `test('name', ...)` line of a *.test.js file is one test; a test whose line says `fail` fails, with a
// diffable message when the line also has `expected "..." actual "..."` (JSON strings), a markdown one when it has
-// `markdown "..."`, and a call stack when it has `stack`: a frame at the test's line and one without a source.
+// `markdown "..."`, ANSI colors when it has `ansi`, and a call stack when it has `stack`: a frame at the test's line and one without a source.
// The Coverage profile reports each run file's test lines as statements, covered unless the line says `fail`.
const vscode = require('vscode');
@@ -28,9 +28,10 @@ exports.activate = async function (context) {
if (line.includes('fail')) {
const diff = /expected (".*") actual (".*")/.exec(line);
const markdown = /markdown (".*")/.exec(line);
+ const ansi = line.includes('ansi');
const message = diff
? vscode.TestMessage.diff('Expected values to be strictly equal', JSON.parse(diff[1]), JSON.parse(diff[2]))
- : new vscode.TestMessage(markdown ? new vscode.MarkdownString(JSON.parse(markdown[1])) : `${match[1]} failed`);
+ : new vscode.TestMessage(markdown ? new vscode.MarkdownString(JSON.parse(markdown[1])) : ansi ? '\x1b[31mred\x1b[0m, \x1b[42mgreen fill\x1b[0m, \x1b[4munderline\x1b[0m' : `${match[1]} failed`);
if (line.includes('stack')) {
message.stackTrace = [
new vscode.TestMessageStackFrame(match[1], item.uri, new vscode.Position(index, 2)),
diff --git a/port/fixtures/testing-messages/ansi.test.js b/port/fixtures/testing-messages/ansi.test.js
new file mode 100644
index 00000000000..10653e552c0
--- /dev/null
+++ b/port/fixtures/testing-messages/ansi.test.js
@@ -0,0 +1 @@
+test('fails in color', () => {}); // ansi
diff --git a/port/ledger.md b/port/ledger.md
index 4b1e9f4b16a..6b94d2d462d 100644
--- a/port/ledger.md
+++ b/port/ledger.md
@@ -602,7 +602,7 @@ One row per upstream unit, generated by `bun port/tools/gen-ledger.ts`; mileston
| workbench/contrib/telemetry | workbench contribution | M19 | verified | | the contribution logs to the NullTelemetryService and registers Show Telemetry only when supportsTelemetry, false in the built product: nothing to port; port/tools/telemetry-source-check no endpoint in 18370 shipped files (SELF_TEST finds 9 in the inert packages) |
| workbench/contrib/terminal | workbench contribution | M15 | verified | | workbench/terminal_view.rs, workbench/terminal_decorations.rs, terminal/marks.rs, terminal/serialize_html.rs, terminal/label.rs: cargo test -p app new_with_profile a_ctrl_d_exit_shows_no_exit_alert terminal::marks serialize_html terminal_decorations hover a_recording_keeps_each_kind_of_event toggle_visibility_writes_the_decorations_setting the_cwd_setting_resolves_its_variables terminal::label terminal_view::tests paths_are_quoted call_operator a_tab_row_is_inset_and_its_label_is_one_line_of_text panel_terminals_revive_in_their_groups_after_a_restart a_terminal_editor_revives_with_its_history_after_a_restart; ui-pair OSC 99, decorations, overview ruler, Copy as HTML, Record Terminal Session, terminal tabs (port/results/terminal.md), m12/folder-terminal.json (but the reference's Ports overflow, removed), m11/task-presentation.json (port/results/manage-menu.md) |
| workbench/contrib/terminalContrib | workbench contribution | M15 | verified | | terminal/link_parsing.rs, link_computer.rs, workbench/terminal_links.rs, terminal/auto_replies.rs, terminal/search.rs, workbench/terminal_find.rs, terminal/prompt_input.rs, workbench/terminal_suggest.rs, terminal/history.rs, workbench/terminal_quick_access.rs, terminal/sticky_scroll.rs, workbench/terminal_environment.rs, terminal/osc99.rs, terminal/quick_fix.rs, terminal/accessible_buffer.rs, workbench/terminal_initial_hint.rs: cargo test -p app link_ terminal::search prompt_input auto_replies terminal_contrib terminal_links terminal::history sticky_scroll quick_access environment_collection terminal::marks osc99 quick_fix accessible; ui-pair Run Recent Command, `term `, sticky scroll, the initial hint. No counterpart: Show Terminal Texture Atlas, Restart Pty Host. Removed: Copilot CLI, chat and voice (AI), wslRecommendation (Windows) (port/notes.md milestone 15) |
-| workbench/contrib/testing | workbench contribution | M16 | ported | [3 M] testing_results.rs `results_content`: a markdown message's text cannot be selected (`userSelect: text`); the content and tree split in half where the reference splits them about 2:1 (testResultsViewContent.ts `SplitView`); a plain text message's ANSI colors are stripped (`colorizeTestMessageInEditor`); a call stack frame's editor has no Cmd+click to the word's location (callStackWidget.ts `ClickToLocationContribution`)<br>[3 L] testing_coverage_view.rs: no inline coverage (codeCoverageDecorations.ts `CoverageToolbarWidget`, `testing.toggleInlineCoverage`, the line hover, `testing.coverage.goToNextMissedLine` and `goToPreviousMissedLine`), no Filter Coverage by Test or coverage actions in the editor title (`MenuId.EditorTitle`), no percent in the Explorer (`testing.showCoverageInExplorer`), no minimap or overview ruler marks (`testing.coverageMinimapEnabled`), no declaration rows under a file in the Test Coverage view (testCoverageView.ts `DeclarationCoverageNode`), the high-contrast gutter draws fills instead of testing.css's 3px/5px borders | cargo test -p app testing:: testing_filter coverage the_results_tree_shows_tasks_tests_and_messages_as_testresultstree the_results_tree_moves_its_focus_with_the_list_commands a_results_rows_menu_shows_its_actions_and_the_contributed_items an_opened_ the_gutter_menu_shows_the_tests_actions_before_the_line_number_items a_line_with_two_tests_shows_run_all_and_a_submenu_per_test reveal_in_test_explorer_expands_the_tests_parents the_run_group_dropdown_lists_its_profiles_and_runs_the_picked_one select_default_profile_stores_the_picked_defaults the_run_group_chevron_keeps_the_view_title_actions_in_the_side_bar runs_from_the_explorer_exclude_the_tests_the_filter_hides a_hidden_test_leaves_the_tree_and_runs_until_it_is_unhidden a_test_row_shows_the_test_item_menu_s_inline_group a_test_rows_context_menu_shows_and_runs_the_test_item_actions children_sort_by_line_then_by_file_name_order the_view_title_dropdown_starts_and_stops_one_profile_of_several continuous_run_using_picks_from_the_tests_controller_only a_continuous_run_holds_one_cancellable_request_per_profile_until_it_stops the_testing_item_spins view_as_list_shows_the_leaves_and_the_more_menu_checks_the_mode peek_error_opens_the_failed_childs_message_at_the_test a_test_run_waits_for_workspace_trust_and_completes_when_it_is_refused task_and_test_output_show_in_a_detached_terminal a_contributed_inline_result_action_draws_its_icon retired_tests_take_test_result_outdated a_line_with_more_than_30_tests_picks_the_rest_from_a_quick_pick reveal_in_test_explorer_selects_and_scrolls_to_the_row the_run_group_chevron_is_active_while_its_menu_is_open the_workbench_context_has_the_testing_service_keys; ui-pair port/fixtures/debug-node with tests-provider (Testing tree, Run All, results tree, row menus, opened message, run glyphs and the gutter menu on math.test.js line 2, the run profile dropdown); ui-pair port/fixtures/testing-messages (diff message, markdown message output, stack trace); ui-pair m16/coverage.json |
+| workbench/contrib/testing | workbench contribution | M16 | ported | [3 L] testing_coverage_view.rs: no inline coverage (codeCoverageDecorations.ts `CoverageToolbarWidget`, `testing.toggleInlineCoverage`, the line hover, `testing.coverage.goToNextMissedLine` and `goToPreviousMissedLine`), no Filter Coverage by Test or coverage actions in the editor title (`MenuId.EditorTitle`), no percent in the Explorer (`testing.showCoverageInExplorer`), no minimap or overview ruler marks (`testing.coverageMinimapEnabled`), no declaration rows under a file in the Test Coverage view (testCoverageView.ts `DeclarationCoverageNode`), the high-contrast gutter draws fills instead of testing.css's 3px/5px borders | cargo test -p app testing:: testing_filter testing_message_colorizer testing_results:: coverage the_gutter_menu_shows_the_tests_actions_before_the_line_number_items a_line_with_two_tests_shows_run_all_and_a_submenu_per_test reveal_in_test_explorer_expands_the_tests_parents the_run_group_dropdown_lists_its_profiles_and_runs_the_picked_one select_default_profile_stores_the_picked_defaults the_run_group_chevron_keeps_the_view_title_actions_in_the_side_bar runs_from_the_explorer_exclude_the_tests_the_filter_hides a_hidden_test_leaves_the_tree_and_runs_until_it_is_unhidden a_test_row_shows_the_test_item_menu_s_inline_group a_test_rows_context_menu_shows_and_runs_the_test_item_actions children_sort_by_line_then_by_file_name_order the_view_title_dropdown_starts_and_stops_one_profile_of_several continuous_run_using_picks_from_the_tests_controller_only a_continuous_run_holds_one_cancellable_request_per_profile_until_it_stops the_testing_item_spins view_as_list_shows_the_leaves_and_the_more_menu_checks_the_mode peek_error_opens_the_failed_childs_message_at_the_test a_test_run_waits_for_workspace_trust_and_completes_when_it_is_refused a_line_with_more_than_30_tests_picks_the_rest_from_a_quick_pick reveal_in_test_explorer_selects_and_scrolls_to_the_row the_run_group_chevron_is_active_while_its_menu_is_open the_workbench_context_has_the_testing_service_keys; ui-pair port/fixtures/debug-node with tests-provider (Testing tree, Run All, results tree, row menus, opened message, run glyphs and the gutter menu on math.test.js line 2, the run profile dropdown); ui-pair port/fixtures/testing-messages (diff message, markdown message output and selection copy, ANSI message, stack trace and a press in a frame); ui-pair m16/coverage.json |
| workbench/contrib/themes | workbench contribution | M9 | verified | | Color Theme picker (`workbench.action.selectTheme`, Cmd+K Cmd+T): rows, order and descriptions as the reference, 200ms preview, Escape restores, accept writes `workbench.colorTheme`; File Icon Theme picker (`workbench.action.selectIconTheme`, Themes submenu): None and the installed themes, preview, Escape restores, accept writes `workbench.iconTheme` (null for None) (cargo test -p app themes); Product Icon Theme picker (`workbench.action.selectProductIconTheme`, Themes submenu): Default and the installed themes, writes `workbench.productIconTheme` (cargo test -p app product_icon; product-icons-pair `picker`: the same rows, except the reference's "Test Product Icon Theme" of vscode-colorize-tests, a test extension the port does not ship); no Marketplace browsing, no `window.autoDetectColorScheme` |
| workbench/contrib/timeline | workbench contribution | M14 | verified | | Timeline view (workbench/timeline_view.rs, timeline.rs): active editor and workspace timelines, paging, follow active editor, excluded sources in profile storage, compare selected, keyboard, `timeline/item/context` and title menus: cargo test -p app timeline; the title toolbar is a tab stop between the pane header and the tree (Shift+Tab focuses its first action with its hover, Left/Right, Enter): cargo test -p app shift_tab_reaches_the_title_toolbar; ui-pair m12/timeline.json header step matches; item labels draw their `$(icon)`s (cargo test -p app an_item_label_draws_its_icons); a `null` `timeline.pageSize` follows the view height (cargo test -p app a_null_page_size_follows_the_view_height) |
| workbench/contrib/typeHierarchy | workbench contribution | M13 | verified | | Peek Type Hierarchy in workbench/hierarchy_peek.rs: supertypes/subtypes toggle, layout `typeHierarchyPeekLayout`, the focused message of an empty answer, `_executePrepareTypeHierarchy`, `_executeProvideSupertypes`, `_executeProvideSubtypes`; cargo test -p app hierarchy; ui-pair port/results/language-features.md (Type hierarchy) |
diff --git a/port/notes.md b/port/notes.md
index 67eda1d75cd..96e1989363b 100644
--- a/port/notes.md
+++ b/port/notes.md
@@ -880,7 +880,7 @@ Scope as in the M19 Work row of port/ledger.md.
- Test Explorer title (testExplorerActions.ts, `testing_view.rs`): the navigation actions end with Show Output (`terminal`, disabled until a result exists); the "..." holds View as List/Tree, Sort by Status/Location/Duration (workspace storage `testing.viewMode` and `testing.viewSorting`, as testingExplorerView.ts) and Collapse All Tests, Clear All Results. Shortcut: View as List lists the tests the collection has resolved; listProjection.ts also asks the controller to resolve every level (`expandElement(root, Infinity)`), which the port does not send.
- Test Results tree (`workbench/testing_results.rs`; testResultsTree.ts `OutputPeekTree`): rows drawn as the workbench tree rows (4px inset, rounded, `list_row_selection`, indent guides, listCommands.ts keys while focused); a new run selects and focuses its first task without taking the focus (`revealItem` with `preserveFocus`). Decision: the task row always shows its twistie when it has children. The reference renders the task row while the task is still childless (`onNewTask`), and abstractTree.ts `renderTreeElement` redraws a twistie only on a collapse state change, so the reference shows no twistie until the row is toggled or rendered again; the port draws the state a fresh render gives.
- Test resolution timing: treeProjection.ts `storeItem` expands only depth-0 items, the controller roots; a single root's children show on the explorer's top level collapsed (index.ts `getChildrenForParent`, `depth > 0`) and resolve only when the user expands them, and testService.ts `testsInFile` yields an open file's item without expanding it. The port expanded those file items at publish, so the tests-provider fixture's `resolveHandler` ran for every file and Run All ran each test, where the reference's run handler finds the unresolved file item and runs it as one test (`math.test.js` without children in the results). `TestCollection::apply` now answers only the roots.
-- Test Results content editors (`workbench/testing_results.rs`; testResultsOutput.ts content providers): the view's code editors live in `TEST_RESULTS_GROUP`, a group outside the grid like the Output view's `PANEL_GROUP` (`is_panel_group`), so they select, copy and take the editor keys through the same code; `PlainTextMessagePeek` opens a plain text message's `messageUri` model (`vscode-test-data://results/<result>/message/<task>/<message>/TestFailureMessage?<test>`) there read-only, without line numbers, glyph margin, minimap or `scrollBeyondLastLine` (`commonEditorOptions`). Shortcut: ANSI escapes in the message are stripped, not colored as `colorizeTestMessageInEditor` does. `DiffContentProvider` opens a diffable message (an error with string `expected` and `actual`) as an embedded diff of its `ExpectedOutput` and `ActualOutput` models (`DiffInput.embedded`): `diffEditorOptions` fixes the options (side by side, no overview ruler, `ignoreTrimWhitespace` false, unchanged regions shown) instead of reading `diffEditor.*`, line numbers turn on when either side is multiline, and a 20px zone above line 1 holds the "Expected" and "Actual" titles (testingDecorations.ts `TitleLensContentWidget`). The editors are built outside a text editor part, so `lineNumbersMinChars` is the default 5, and only the original side has a glyph margin (`_adjustOptionsForLeftHandSide`). The diff's `diff_part_width` moved to the group state, since the results diff and an editor area diff lay out at once. ui-pair port/fixtures/testing-messages (`compare.test.js`): gutters, fills and titles match; the reference splits the content and tree about 2:1 where the port splits them in half (`TestResultsViewContent.lastSplitWidth`), open. `MarkdownTestMessagePeek` renders a markdown message through `markdown_view.rs` in testing.css `.preview-text` (8px 12px 8px 20px padding, paragraphs 1em apart at `line-height: normal`, 15px here), and its results row reads the rendered text (`renderTestMessageAsText`). ui-pair of a `markdown "..."` test (tests-provider): text box 240x77 at the same left in both, 1px lower in the reference. `TerminalMessagePeek` writes a task's output, a test's output or an output message's range into a detached terminal (`TerminalView.detached`: an `extension_pty` instance with ids counting down from `u32::MAX`, kept out of the terminal list), appending when the earlier text is its prefix and resetting with `\x1bc` otherwise; an empty finished output writes the `formatMessageForTerminal` notice. It attaches with `enableGpu: false`, so the DomRenderer lays the cells out on the unrounded advance (Menlo 12: 7.2px, `CellMetrics.dom_cell_width`), not the WebGL renderer's whole device pixels. ui-pair of the `markdown "..."` test's output: the line is 385px wide in the reference and 384px in the port, at the same origin. A message's `stackTrace` (testResultsSubject.ts `MessageSubject.stack`) shows as callStackWidget.ts `CallStackWidget`: a 24px header per frame (collapse button, label, toolbar), the message's frame first with `MenuId.TestCallStack` (Rerun Test, Debug Test by the test's capabilities), then each frame with a readable source as a read-only peek editor in `TEST_RESULTS_GROUP` (`PeekOwner::CallStackFrame`, kept out of host sync) showing its line and 2 around it through hidden areas, the line highlighted as the top stack frame and its column marked, with `MenuId.DebugCallStackToolbar`'s Open File; a frame without a source shows its label, `:line` and "Line N column M". The frame editors take only `ClickToLocationContribution` upstream, so no test glyphs, overview ruler or scrollbars, and `lineNumbersMinChars` 5. The column marker's width is in columns of the measured font: the results group copies an editor-less main group's viewport with no `char_width`, so the view marks the columns itself (`sync_call_stack_frame_columns`). ui-pair of `stack.test.js` (tests-provider sets `stackTrace` on a `stack` line): headers, labels, gutter and the frame line match; the 2:1 split is the open difference above. Cmd+click in a frame editor (`ClickToLocationContribution`) is not ported.
+- Test Results content editors (`workbench/testing_results.rs`; testResultsOutput.ts content providers): the view's code editors live in `TEST_RESULTS_GROUP`, a group outside the grid like the Output view's `PANEL_GROUP` (`is_panel_group`), so they select, copy and take the editor keys through the same code; `PlainTextMessagePeek` opens a plain text message's `messageUri` model (`vscode-test-data://results/<result>/message/<task>/<message>/TestFailureMessage?<test>`) there read-only, without line numbers, glyph margin, minimap or `scrollBeyondLastLine` (`commonEditorOptions`). testMessageColorizer.ts `colorizeTestMessageInEditor` (`testing_message_colorizer.rs`): the model holds the text without its escapes (strings.ts `removeAnsiEscapeCodes`) and each styled run is a text decoration keyed by its space-joined `tstm-ansidec-*` classes; only single-number SGR codes change the state (`colorAttrRe`, so `\x1b[1;31m` does nothing), and only `bg30`-`bg37` and `bg100`-`bg107` have a fill, as testMessageColorizer.css has rules for those alone. `DiffContentProvider` opens a diffable message (an error with string `expected` and `actual`) as an embedded diff of its `ExpectedOutput` and `ActualOutput` models (`DiffInput.embedded`): `diffEditorOptions` fixes the options (side by side, no overview ruler, `ignoreTrimWhitespace` false, unchanged regions shown) instead of reading `diffEditor.*`, line numbers turn on when either side is multiline, and a 20px zone above line 1 holds the "Expected" and "Actual" titles (testingDecorations.ts `TitleLensContentWidget`). The editors are built outside a text editor part, so `lineNumbersMinChars` is the default 5, and only the original side has a glyph margin (`_adjustOptionsForLeftHandSide`). The diff's `diff_part_width` moved to the group state, since the results diff and an editor area diff lay out at once. ui-pair port/fixtures/testing-messages (`compare.test.js`): gutters, fills and titles match; the content and tree split about 2:1 in both: testResultsViewContent.ts adds them with `Sizing.Distribute` to a split view of size 0, so they start at their minimums (200 and 100) and the proportional layout keeps that ratio, which the port gives as flex weights 2 and 1 over those minimum widths. `MarkdownTestMessagePeek` renders a markdown message through `markdown_view.rs` in testing.css `.preview-text` (8px 12px 8px 20px padding, paragraphs 1em apart at `line-height: normal`, 15px here), and its results row reads the rendered text (`renderTestMessageAsText`). ui-pair of a `markdown "..."` test (tests-provider): text box 240x77 at the same left in both, 1px lower in the reference. The text is selectable (testResultsOutput.ts `userSelect: text`): GPUI text has no selection, so `markdown_view.rs` `selectable_markdown_blocks` keeps each text's layout and bounds in `MarkdownSelection`, drags and double clicks select across the blocks, and Copy takes the selection when no editor or input has the focus, with Chrome's `\n\n` between blocks. Without `selection.background` it paints Chrome's `::selection` default as measured (#567BA1 dark, #B0D4FB light). ui-pair of a drag over both paragraphs: the same copied text and highlight, except Chrome's highlight of the line break past a paragraph's last character. `TerminalMessagePeek` writes a task's output, a test's output or an output message's range into a detached terminal (`TerminalView.detached`: an `extension_pty` instance with ids counting down from `u32::MAX`, kept out of the terminal list), appending when the earlier text is its prefix and resetting with `\x1bc` otherwise; an empty finished output writes the `formatMessageForTerminal` notice. It attaches with `enableGpu: false`, so the DomRenderer lays the cells out on the unrounded advance (Menlo 12: 7.2px, `CellMetrics.dom_cell_width`), not the WebGL renderer's whole device pixels. ui-pair of the `markdown "..."` test's output: the line is 385px wide in the reference and 384px in the port, at the same origin. A message's `stackTrace` (testResultsSubject.ts `MessageSubject.stack`) shows as callStackWidget.ts `CallStackWidget`: a 24px header per frame (collapse button, label, toolbar), the message's frame first with `MenuId.TestCallStack` (Rerun Test, Debug Test by the test's capabilities), then each frame with a readable source as a read-only peek editor in `TEST_RESULTS_GROUP` (`PeekOwner::CallStackFrame`, kept out of host sync) showing its line and 2 around it through hidden areas, the line highlighted as the top stack frame and its column marked, with `MenuId.DebugCallStackToolbar`'s Open File; a frame without a source shows its label, `:line` and "Line N column M". The frame editors take only `ClickToLocationContribution` upstream, so no test glyphs, overview ruler or scrollbars, and `lineNumbersMinChars` 5. The column marker's width is in columns of the measured font: the results group copies an editor-less main group's viewport with no `char_width`, so the view marks the columns itself (`sync_call_stack_frame_columns`). ui-pair of `stack.test.js` (tests-provider sets `stackTrace` on a `stack` line): headers, labels, gutter and the frame line match; Cmd+click on a word in a frame editor (`ClickToLocationContribution`) underlines it as a link without a definition lookup and opens the frame's file with the cursor at the word's start, to the side with the side-by-side modifier (`goto_definition_link.rs` `open_call_stack_word`). The results group draws through `swapped_group_body`, whose guard keeps unpressed moves from a group that is not active, so the press links the word itself. That guard focused the group in its own capture listener, painted after the body, so a frame editor's capture took the focus in the wrong group first and the row's press read the message editor's lines (an index panic); the body's capture listener focuses the group now. A press that focuses a frame's editor makes it the active one, so the message row draws its editor as an unfocused code editor (`embedded_code_editor`) rather than the active one. ui-pair cannot hold Cmd through a press (cua's `modifier` reaches neither app as a held key, no link shows in the reference either), so `cmd_click_on_a_word_in_a_frame_opens_its_file_there` is the evidence; a plain press in the frame matches the reference.
- Continuous run (`workbench/testing_continuous.rs`): the view title's dropdown of `getContinuousRunDropdown` runs plain actions upstream; the port's context menu runs commands, so each profile item is an internal `_testing.toggleContinuousRunProfile.<controller>.<profile>` command registered when the menu shows. testingExplorerView.ts re-sorts a parent when a continuous run changes, but `TreeSorter` has no continuous run criterion in 1.147.0, so the order does not change; the port draws rows from the run state each frame and needs no re-sort. The unattended restart participant `testing.continuousRun` waits on the unattended restart service (ledger row workbench/services/lifecycle).
- Inline values (`workbench/debug_inline_values.rs`; debugEditorContribution.ts): `debug.inlineValues` `on` or `auto` with a provider shows the focused frame's values as `InjectionOwner::DebugInlineValue` text after the lines, `editor.inlineValuesForeground` on `editor.inlineValuesBackground`. Shortcuts: only the active editor shows them, where upstream decorates every editor on the frame's file; the scopes and variables are fetched again, not shared with the Variables view's cache; the text area width stands in for `layoutInfo.width` in the line length cut.
- Debug hover (`workbench/debug_hover.rs`; debugHover.ts, debugEditorContribution.ts hover handling): while stopped, the expression at the mouse in the focused frame's file (the first `EvaluatableExpressionProvider` through `$provideEvaluatableExpression`, else `getExactExpressionStartAndEnd`) is evaluated with `context: "hover"` (or looked up in the cheap scopes without `supportsEvaluateForHovers`) after the doubled `editor.hover.delay`, the editor hover off meanwhile; Alt swaps it for the editor hover; Cmd+K Cmd+I shows it at the cursor. The focused tree takes listWidget.ts's and abstractTree.ts's keys through the `list.*` commands (Up, Down, Page Up, Page Down, Home, End, Left, Right, Space, Enter, type navigation by name), Escape clears a selection before it hides the widget; `layoutTree` sizes the tree to its rows plus 10px, at most max(266px, 55% of the editor) and the hovered line's top less 22px. The visualizers are a ledger gap of workbench/contrib/debug; the context menu is under Variable menus. The glyph margin lifts the editor hover lockout; the hovered position is the nearer edge of the character under the mouse, a tab's middle included. Lazy rows (`presentationHint.lazy`) draw the `$(eye)` button after the name in the hover, Variables and Watch trees; a lazy watch, hover or REPL result is evaluated at once (debugModel.ts `evaluateExpression` without `keepLazyVars`). A click on an expandable row focuses and toggles it; with Alt the descendants whose children are loaded follow, the others stay collapsed (indexTreeModel.ts `_setNodeCollapseState` recursive, asyncDataTree.ts collapsing a stale node a deep expand reaches). `list.find` (Cmd+Alt+F, F3) on the focused tree opens abstractTree.ts's find widget over 30px of padding: highlight or filter mode and fuzzy or contiguous match by `workbench.list.defaultFindMode` and `defaultFindMatchType` and the widget's toggles, the filter keeps a collapsed parent of a loaded match, "No results found.", the focus to the first match from the focused row; it outlives each shown value like the tree, and Escape hides the hover and runs `list.closeFind` after it. ui-pair on `port/fixtures/debug-node` (Cmd+K Cmd+I on `numbers` and `greeting`) matches the reference's placement, tree indent and focus outline.