Skip to content

Visual Studio Code, rebuilt in Rust

Rust

feat(testing): show inline coverage and its toolbar in the editor

rokartur99caa36b7ed6
diff --git a/native/crates/app/src/editor/injected_text.rs b/native/crates/app/src/editor/injected_text.rs
index fc5aa2b1bb6..5fd30935cde 100644
--- a/native/crates/app/src/editor/injected_text.rs
+++ b/native/crates/app/src/editor/injected_text.rs
@@ -23,6 +23,8 @@ pub enum InjectionOwner {
StackFrameColumn,
/// An inline breakpoint or candidate's `debug-breakpoint-placeholder` (breakpointEditorContribution.ts).
InlineBreakpoint,
+ /// An inline coverage count badge or missed-branch indicator (codeCoverageDecorations.ts `countBadge`).
+ Coverage,
}
impl InjectionOwner {
@@ -33,7 +35,7 @@ impl InjectionOwner {
match self {
InjectionOwner::InlayHint => CursorStops::Right,
// A debug inline value's `InjectedTextCursorStops.None` sits at the line's end, where Left is the one stop.
- InjectionOwner::GhostText | InjectionOwner::DecorationContent | InjectionOwner::DebugInlineValue => CursorStops::Left,
+ InjectionOwner::GhostText | InjectionOwner::DecorationContent | InjectionOwner::DebugInlineValue | InjectionOwner::Coverage => CursorStops::Left,
InjectionOwner::Color | InjectionOwner::InlineProgress | InjectionOwner::StackFrameColumn | InjectionOwner::InlineBreakpoint => CursorStops::Both,
}
}
diff --git a/native/crates/app/src/menus.rs b/native/crates/app/src/menus.rs
index e648b92bf0c..960f4e5dabe 100644
--- a/native/crates/app/src/menus.rs
+++ b/native/crates/app/src/menus.rs
@@ -216,16 +216,17 @@ pub enum Entry {
Submenu { submenu: MenuId, toggled: Option<Expr> },
}
-/// `ICommandAction.toggled`: checked while `condition` holds, with `title` as the label then.
+/// `ICommandAction.toggled`: checked while `condition` holds, with `title` as the label and `icon` as the codicon then.
#[derive(Clone, Debug)]
pub struct Toggled {
pub condition: Expr,
pub title: Option<String>,
+ pub icon: Option<String>,
}
impl Toggled {
pub fn when(condition: Option<Expr>) -> Option<Self> {
- condition.map(|condition| Self { condition, title: None })
+ condition.map(|condition| Self { condition, title: None, icon: None })
}
}
@@ -939,6 +940,17 @@ pub fn workbench_menus() -> Vec<MenuItem> {
let entry = Entry::Command { id: id.into(), precondition: None, toggled: Toggled::when(Some(Expr::has(toggled))), alt: None };
items.push(MenuItem { menu, entry, title: title.into(), group: group.into(), order, when: Expr::deserialize(when) });
}
+ // codeCoverageDecorations.ts ToggleInlineCoverage and FilterCoverageToTestInEditor: editor title icons while the
+ // coverage toolbar, which holds them otherwise, is off.
+ let coverage_title_actions = [
+ ("testing.toggleInlineCoverage", "Toggle Inline Coverage", "testing.inlineCoverageEnabled", Some("Hide Inline Coverage"), None, "testing.hasInlineCoverageDetails && testing.coverageToolbarEnabled != true"),
+ ("testing.coverageFilterToTestInEditor", "Filter Coverage to Test", "testing.isCoverageFilteredToTest", None, Some("filter-filled"), "testing.hasCoverageInFile && testing.coverageToolbarEnabled != true && testing.hasPerTestCoverage && activeEditor == 'workbench.editors.files.textFileEditor'"),
+ ];
+ for (id, title, toggled, toggled_title, toggled_icon, when) in coverage_title_actions {
+ let toggled = Toggled { condition: Expr::has(toggled), title: toggled_title.map(Into::into), icon: toggled_icon.map(Into::into) };
+ let entry = Entry::Command { id: id.into(), precondition: None, toggled: Some(toggled), alt: None };
+ items.push(MenuItem { menu: MenuId::EditorTitle, entry, title: title.into(), group: "navigation".into(), order: 0., when: Expr::deserialize(when) });
+ }
// inlineCompletions/browser/controller/commands.ts ToggleAlwaysShowInlineSuggestionToolbar.
let toggled = Toggled::when(Expr::deserialize("config.editor.inlineSuggest.showToolbar == 'always'"));
let entry = Entry::Command { id: ALWAYS_SHOW_INLINE_TOOLBAR.into(), precondition: None, toggled, alt: None };
@@ -1145,7 +1157,7 @@ pub fn command_icons(extensions: &[ScannedExtension]) -> std::collections::HashM
icons.insert("workbench.files.action.acceptLocalChanges".to_string(), CommandIcon::Codicon("check".into()));
icons.insert("workbench.files.action.revertLocalChanges".to_string(), CommandIcon::Codicon("discard".into()));
// testing icons.ts: a test row's inline actions and the call stack's; callStackWidget.ts `Codicon.goToFile`.
- for (id, icon) in [("testing.run", "run"), ("testing.debug", "debug-alt-small"), ("testing.coverage", "run-coverage"), ("testing.callStack.run", "run"), ("testing.callStack.debug", "debug-alt-small"), ("callStackWidget.goToFile", "go-to-file")] {
+ for (id, icon) in [("testing.toggleInlineCoverage", "coverage"), ("testing.coverageFilterToTestInEditor", "filter"), ("testing.run", "run"), ("testing.debug", "debug-alt-small"), ("testing.coverage", "run-coverage"), ("testing.callStack.run", "run"), ("testing.callStack.debug", "debug-alt-small"), ("callStackWidget.goToFile", "go-to-file")] {
icons.insert(id.to_string(), CommandIcon::Codicon(icon.into()));
}
// notebookIcons.ts: the cell toolbar's buttons.
diff --git a/native/crates/app/src/menus/tests.rs b/native/crates/app/src/menus/tests.rs
index 675f5c602bb..d46fb17f574 100644
--- a/native/crates/app/src/menus/tests.rs
+++ b/native/crates/app/src/menus/tests.rs
@@ -94,7 +94,7 @@ fn a_submenu_of_empty_submenus_is_left_out() {
#[test]
fn enablement_toggled_title_and_alt_precondition() {
let mut item = command("command", "Command", "", 0.);
- let toggled = Some(Toggled { condition: Expr::has("toggled"), title: Some("Toggled".into()) });
+ let toggled = Some(Toggled { condition: Expr::has("toggled"), title: Some("Toggled".into()), icon: None });
let alt = Some(Alt { id: "alt".into(), title: "Alternate".into(), precondition: Some(Expr::has("enabled")) });
item.entry = Entry::Command { id: "command".into(), precondition: Some(Expr::has("enabled")), toggled, alt };
let registry = [item];
diff --git a/native/crates/app/src/testing_coverage.rs b/native/crates/app/src/testing_coverage.rs
index f6e30bcb576..840f9e4b69a 100644
--- a/native/crates/app/src/testing_coverage.rs
+++ b/native/crates/app/src/testing_coverage.rs
@@ -548,3 +548,101 @@ pub fn detail_ranges(details: &[CoverageDetail]) -> Vec<DetailRange> {
}
result
}
+
+/// codeCoverageDecorations.ts `apply`'s inline options of one statement or branch range (`applyHoverOptions`), in
+/// 0-based model positions (`validateRange`): the `coverage-deco-inline` fill unless it is a missed branch's
+/// indicator, and the `countBadge` before it. `detail` and `branch` describe it for the hover.
+#[derive(Clone, Debug, PartialEq)]
+pub struct InlineCoverage {
+ pub start: (usize, usize),
+ pub end: (usize, usize),
+ pub hit: bool,
+ /// `coverage-deco-branch-miss-indicator`: a missed branch with an empty range in a statement that ran.
+ pub branch_miss: bool,
+ pub count: Option<String>,
+ pub detail: usize,
+ pub branch: Option<usize>,
+}
+
+pub fn inline_coverage(details: &[CoverageDetail], lines: &[String]) -> Vec<InlineCoverage> {
+ let mut inline = Vec::new();
+ for range in detail_ranges(details) {
+ let Some(hit) = range.hit(details) else { continue };
+ let detail = &details[range.detail];
+ let (count, branch_miss) = match range.branch {
+ // A condition that never ran shows no miss indicator.
+ Some(branch) => (detail.branches[branch].count, !hit && range.range.is_empty() && detail.branches.iter().any(|branch| branch.count.is_hit())),
+ None => (detail.count, false),
+ };
+ let count = match count {
+ HitCount::Times(times) if range.primary && times > 0 && !branch_miss => Some(if times > 99 { "99+x".to_owned() } else { format!("{times}x") }),
+ _ => None,
+ };
+ let (start, end) = (model_position(lines, range.range.start), model_position(lines, range.range.end));
+ inline.push(InlineCoverage { start, end, hit, branch_miss, count, detail: range.detail, branch: range.branch });
+ }
+ inline
+}
+
+/// `CoverageDetailsModel.describe` of a statement or one of its branches, as markdown.
+pub fn describe(details: &[CoverageDetail], detail: usize, branch: Option<usize>, lines: &[String]) -> String {
+ let detail = &details[detail];
+ let text = text_in_range(lines, detail.location);
+ let text = wrap_name(if text.trim().is_empty() { "<empty statement>" } else { text.trim() });
+ if let Some(branch) = branch {
+ let branch_detail = &detail.branches[branch];
+ let label = branch_detail.label.as_deref().map_or(format!("#{}", branch + 1), wrap_in_backticks);
+ return match branch_detail.count {
+ HitCount::Times(0) | HitCount::Ran(false) => format!("Branch {label} in {text} was not covered."),
+ HitCount::Ran(true) => format!("Branch {label} in {text} was executed."),
+ HitCount::Times(times) => format!("Branch {label} in {text} was executed {times} time(s)."),
+ };
+ }
+ if !detail.branches.is_empty() {
+ let covered = detail.branches.iter().filter(|branch| branch.count.is_hit()).count();
+ return format!("{covered} of {} of branches in {text} were covered.", detail.branches.len());
+ }
+ // `namedDetailLabel` around the already wrapped name: upstream's double backticks.
+ match detail.count {
+ HitCount::Times(0) | HitCount::Ran(false) => format!("`{text}` was not executed."),
+ HitCount::Times(times) => format!("`{text}` was executed {times} time(s)."),
+ HitCount::Ran(true) => format!("`{text}` was executed."),
+ }
+}
+
+/// `validatePosition`: a 1-based position clamped to the model, as a 0-based line and column.
+fn model_position(lines: &[String], position: CoveragePosition) -> (usize, usize) {
+ let line = (position.line as usize).max(1);
+ if line > lines.len() {
+ return (lines.len() - 1, lines[lines.len() - 1].chars().count());
+ }
+ let length = lines[line - 1].chars().count();
+ (line - 1, (position.column as usize).clamp(1, length + 1) - 1)
+}
+
+/// `getValueInRange`, lines joined with `\n`.
+fn text_in_range(lines: &[String], range: CoverageRange) -> String {
+ let (start, end) = (model_position(lines, range.start), model_position(lines, range.end));
+ let mut text = String::new();
+ for line in start.0..=end.0 {
+ let chars = lines[line].chars();
+ let from = if line == start.0 { start.1 } else { 0 };
+ let to = if line == end.0 { end.1 } else { usize::MAX };
+ text.extend(chars.skip(from).take(to.saturating_sub(from)));
+ if line < end.0 {
+ text.push('\n');
+ }
+ }
+ text
+}
+
+fn wrap_in_backticks(text: &str) -> String {
+ format!("`{}`", text.replace(['\n', '\r', '`'], ""))
+}
+
+fn wrap_name(name: &str) -> String {
+ match name.chars().count() > 50 {
+ true => wrap_in_backticks(&format!("{}...", name.chars().take(40).collect::<String>())),
+ false => wrap_in_backticks(name),
+ }
+}
diff --git a/native/crates/app/src/testing_coverage/tests.rs b/native/crates/app/src/testing_coverage/tests.rs
index 0804c9911be..fea550434fd 100644
--- a/native/crates/app/src/testing_coverage/tests.rs
+++ b/native/crates/app/src/testing_coverage/tests.rs
@@ -150,3 +150,26 @@ fn coverage_color_takes_the_closest_threshold_below() {
assert_eq!(coverage_color(0.6, &thresholds), "charts.yellow");
assert_eq!(coverage_color(0.95, &thresholds), "charts.green");
}
+
+#[test]
+fn inline_coverage_badges_primary_counts_and_marks_missed_empty_branches() {
+ let lines: Vec<String> = ["if (a) {", " b();", "}"].map(str::to_owned).into();
+ let mut branchy = statement(range((1, 1), (3, 2)), 150);
+ branchy["branches"] = json!([{ "location": range((2, 3), (2, 7)), "count": 3 }, { "location": range((3, 2), (3, 2)), "count": 0, "label": "else" }]);
+ let details: Vec<CoverageDetail> = [branchy, statement(range((2, 3), (2, 7)), 0)].iter().map(|detail| CoverageDetail::from_value(detail).unwrap()).collect();
+ let shown: Vec<_> = inline_coverage(&details, &lines).into_iter().map(|range| (range.start, range.end, range.hit, range.branch_miss, range.count)).collect();
+ let count = |count: &str| Some(count.to_owned());
+ assert_eq!(
+ shown,
+ [
+ ((0, 0), (1, 2), true, false, count("99+x")),
+ ((1, 2), (1, 2), false, false, None),
+ ((1, 2), (1, 6), true, false, count("3x")),
+ ((2, 1), (2, 1), false, true, None),
+ ((1, 6), (2, 1), true, false, None),
+ ]
+ );
+ assert_eq!(describe(&details, 0, Some(1), &lines), "Branch `else` in `if (a) { b();}` was not covered.");
+ assert_eq!(describe(&details, 0, None, &lines), "1 of 2 of branches in `if (a) { b();}` were covered.");
+ assert_eq!(describe(&details, 1, None, &lines), "``b();`` was not executed.");
+}
diff --git a/native/crates/app/src/theme.rs b/native/crates/app/src/theme.rs
index 2a24dadd458..c6d554c6d74 100644
--- a/native/crates/app/src/theme.rs
+++ b/native/crates/app/src/theme.rs
@@ -444,7 +444,7 @@ pub(crate) fn color_mix(color: Rgba, amount: f32, background: Rgba) -> Rgba {
/// `Color.makeOpaque`: RGBA's `_clampUint8` truncates each blended byte (`| 0`). The alpha is RGBA's, rounded to 3
/// decimals; the math is JS doubles.
-fn make_opaque(color: Rgba, background: Rgba) -> Rgba {
+pub(crate) fn make_opaque(color: Rgba, background: Rgba) -> Rgba {
let alpha = (color.a as f64 * 1000.).round() / 1000.;
let blend = |c: f32, b: f32| {
let (c, b) = ((c as f64 * 255.).round(), (b as f64 * 255.).round());
diff --git a/native/crates/app/src/theme/debug_colors.rs b/native/crates/app/src/theme/debug_colors.rs
index b0ff373a89e..d0305681156 100644
--- a/native/crates/app/src/theme/debug_colors.rs
+++ b/native/crates/app/src/theme/debug_colors.rs
@@ -52,6 +52,22 @@ pub(super) fn debug_default(key: &str) -> Option<[ColorValue; 4]> {
const UNCOVERED: ColorValue = Transparent(&Key("diffEditor.removedTextBackground"), 1.5);
[UNCOVERED, UNCOVERED, Key("charts.red"), Key("charts.red")]
}
+ "testing.coveredBackground" => [Key("diffEditor.insertedTextBackground"), Key("diffEditor.insertedTextBackground"), ColorValue::None, ColorValue::None],
+ "testing.coveredBorder" => {
+ const BORDER: ColorValue = Transparent(&Key("testing.coveredBackground"), 0.75);
+ [BORDER, BORDER, Key("contrastBorder"), Key("contrastBorder")]
+ }
+ "testing.uncoveredBackground" => [Key("diffEditor.removedTextBackground"), Key("diffEditor.removedTextBackground"), ColorValue::None, ColorValue::None],
+ "testing.uncoveredBorder" => {
+ const BORDER: ColorValue = Transparent(&Key("testing.uncoveredBackground"), 0.75);
+ [BORDER, BORDER, Key("contrastBorder"), Key("contrastBorder")]
+ }
+ "testing.uncoveredBranchBackground" => {
+ const BRANCH: ColorValue = Opaque(&Transparent(&Key("diffEditor.removedTextBackground"), 2.), &Key("editor.background"));
+ [BRANCH, BRANCH, ColorValue::None, ColorValue::None]
+ }
+ "testing.coverCountBadgeBackground" => [Key("badge.background"), Key("badge.background"), Key("badge.background"), Key("badge.background")],
+ "testing.coverCountBadgeForeground" => [Key("badge.foreground"), Key("badge.foreground"), Key("badge.foreground"), Key("badge.foreground")],
"testing.iconPassed" | "testing.runAction" => [Hex("#73c991"), Hex("#73c991"), Hex("#73c991"), Hex("#007100")],
"testing.iconQueued" => [Key("list.warningForeground"), Key("list.warningForeground"), Key("list.warningForeground"), Key("list.warningForeground")],
"testing.iconUnset" | "testing.iconSkipped" => [Hex("#848484"), Hex("#848484"), Hex("#848484"), Hex("#848484")],
diff --git a/native/crates/app/src/workbench.rs b/native/crates/app/src/workbench.rs
index c56166c9905..b2d88f562eb 100644
--- a/native/crates/app/src/workbench.rs
+++ b/native/crates/app/src/workbench.rs
@@ -11,6 +11,7 @@ mod part_navigation;
mod activity_bar_menu;
mod breakpoint_widget;
mod inline_breakpoints;
+mod coverage_decorations;
mod bulk_text_edits;
mod configuration;
mod configuration_migration;
@@ -630,6 +631,7 @@ impl Render for Workbench {
self.follow_hierarchy_peek_editor(window, cx);
self.sync_stack_frame_columns();
self.sync_inline_breakpoints(cx);
+ self.sync_inline_coverage(cx);
// The floating widgets sit on the rows of each file's diff, recomputed after an edit.
self.update_multi_diff_editor();
self.append_multi_diff_layout_logs();
diff --git a/native/crates/app/src/workbench/content_hover.rs b/native/crates/app/src/workbench/content_hover.rs
index 1d8da815d8b..b5a816330e7 100644
--- a/native/crates/app/src/workbench/content_hover.rs
+++ b/native/crates/app/src/workbench/content_hover.rs
@@ -902,6 +902,7 @@ impl Workbench {
parts.extend(self.definition_link_hover_parts(editor, anchor));
parts.extend(self.keybinding_mark_hover_parts(editor, anchor));
parts.extend(self.debug_inline_value_hover_parts(editor, anchor));
+ parts.extend(self.coverage_hover_parts(editor, anchor));
parts.extend(self.inline_completions_hover_parts(editor, anchor));
parts
}
diff --git a/native/crates/app/src/workbench/coverage_decorations.rs b/native/crates/app/src/workbench/coverage_decorations.rs
new file mode 100644
index 00000000000..546be7b83fa
--- /dev/null
+++ b/native/crates/app/src/workbench/coverage_decorations.rs
@@ -0,0 +1,291 @@
+//! codeCoverageDecorations.ts's inline coverage: the `coverage-deco-inline` fill and outline of each statement and
+//! branch, the `countBadge` before it and the missed-branch indicator after it, shown with `showInline` or while
+//! the mouse is over the line numbers, and their `hoverMessage`.
+
+use gpui::{AnyElement, BoxShadow, ClickEvent, Context, Div, MouseButton, MouseDownEvent, PathBuilder, Rgba, Window, canvas, div, point, prelude::*, px};
+use serde_json::json;
+
+use super::Workbench;
+use super::content_hover::{Anchor, Part, PartContent, Participant};
+use super::hover::{HoverContent, HoverOptions};
+use crate::editor::injected_text::{InjectedText, InjectionOwner, LineLayout, WrapWidth};
+use crate::editor::{OpenEditor, Position};
+use crate::testing_coverage::{InlineCoverage, describe, inline_coverage};
+
+/// `BRANCH_MISS_INDICATOR_CHARS` of nbsp.
+const BRANCH_MISS_INDICATOR: &str = "\u{a0}\u{a0}\u{a0}\u{a0}";
+
+impl Workbench {
+ /// `apply` in every editor, run on every render: the file's inline ranges, and the badges and indicators of the
+ /// editors that show them as injected text.
+ pub(super) fn sync_inline_coverage(&mut self, cx: &mut Context<Self>) {
+ let mut inline = std::collections::HashMap::new();
+ let mut wanted = Vec::new();
+ for editor in self.editors.editors.iter().chain(&self.editors.models) {
+ let document = editor.document();
+ let ranges = self.file_coverage(&document.uri()).and_then(|file| Some(inline_coverage(self.coverage_details(&file, cx)?, &document.lines))).unwrap_or_default();
+ wanted.push(if self.shows_inline_coverage(editor.model_id) { self.coverage_injections(&ranges) } else { Vec::new() });
+ inline.insert(editor.model_id, ranges);
+ }
+ self.testing.coverage.inline = inline;
+ for (editor, injections) in self.editors.editors.iter_mut().chain(&mut self.editors.models).zip(wanted) {
+ let current = editor.injected_text.iter().filter(|injection| injection.owner == InjectionOwner::Coverage);
+ if !current.eq(injections.iter()) {
+ editor.set_injected_text(InjectionOwner::Coverage, injections);
+ }
+ }
+ self.sync_coverage_toolbar_zones();
+ }
+
+ /// `CoverageToolbarWidget.show` and `hide`: with `testing.coverageToolbarEnabled`, a 30px zone above the first
+ /// line of each editor whose file has coverage makes room for the toolbar.
+ fn sync_coverage_toolbar_zones(&mut self) {
+ let enabled = self.setting("testing.coverageToolbarEnabled") != false;
+ let shown: Vec<bool> = self.editors.editors.iter().map(|editor| enabled && self.file_coverage(&editor.document().uri()).is_some()).collect();
+ let zones = &mut self.testing.coverage.toolbar_zones;
+ for (editor, shown) in self.editors.editors.iter_mut().zip(shown) {
+ match (zones.get(&editor.model_id).copied(), shown) {
+ (None, true) => drop(zones.insert(editor.model_id, editor.add_view_zone(None, 30.))),
+ (Some(zone), false) => {
+ editor.remove_view_zone(zone);
+ zones.remove(&editor.model_id);
+ }
+ _ => {}
+ }
+ }
+ }
+
+ /// `CoverageToolbarWidget`, a `TOP_CENTER` overlay across the editor: the file's statement, function and branch
+ /// bars, then Go to Previous and Next Uncovered Line, Show or Hide Inline, the per-test filter and Rerun.
+ pub(super) fn coverage_toolbar(&self, editor: &OpenEditor, window: &Window, cx: &mut Context<Self>) -> Option<AnyElement> {
+ self.testing.coverage.toolbar_zones.get(&editor.model_id)?;
+ let file = self.file_coverage(&editor.document().uri())?;
+ let (result, _, _) = self.selected_coverage()?;
+ let has_uncovered = file.statement.covered < file.statement.total;
+ let context = self.key_context(window);
+ let toggle_keybinding = self.keybindings.resolver.lookup_primary_keybinding("testing.toggleInlineCoverage", &context).map(|item| crate::keybindings::label(&item.keybinding));
+ let toggle_label = if self.testing.coverage.show_inline { "Hide Inline" } else { "Show Inline" };
+ let mut actions = vec![
+ self.coverage_toolbar_action("arrow-up", None, "Go to Previous Uncovered Line".into(), has_uncovered, cx, move |workbench: &mut Workbench, window: &mut Window, cx: &mut Context<Workbench>| drop(workbench.execute_command("testing.coverage.goToPreviousMissedLine", Vec::new(), window, cx))),
+ self.coverage_toolbar_action("arrow-down", None, "Go to Next Uncovered Line".into(), has_uncovered, cx, move |workbench: &mut Workbench, window: &mut Window, cx: &mut Context<Workbench>| drop(workbench.execute_command("testing.coverage.goToNextMissedLine", Vec::new(), window, cx))),
+ self.coverage_toolbar_action("coverage", Some(toggle_label), toggle_keybinding.map_or("Toggle Inline".into(), |keybinding| format!("Toggle Inline ({keybinding})")), true, cx, move |workbench: &mut Workbench, window: &mut Window, cx: &mut Context<Workbench>| drop(workbench.execute_command("testing.toggleInlineCoverage", Vec::new(), window, cx))),
+ ];
+ let filter_label = match &self.testing.coverage.filter_to_test {
+ Some(test) => Some(format!("Showing \"{}\"", result.items.get(test.as_str()).map_or("", |item| item.label()))),
+ None => (!file.per_test.is_empty()).then(|| format!("{} test(s) ran code in this file", file.per_test.len())),
+ };
+ if let Some(label) = &filter_label {
+ actions.push(self.coverage_toolbar_action("filter", Some(label), label.clone(), true, cx, move |workbench: &mut Workbench, window: &mut Window, cx: &mut Context<Workbench>| drop(workbench.execute_command("testing.coverageFilterToTestInEditor", Vec::new(), window, cx))));
+ }
+ let running = self.testing.coverage.toolbar_rerun.as_ref().is_some_and(|run| self.testing.results.iter().find(|result| &result.id == run).is_some_and(|result| result.completed_at.is_none()));
+ actions.push(self.coverage_toolbar_action("debug-rerun", Some("Rerun"), "Rerun".into(), !running, cx, |workbench, window, cx| workbench.rerun_coverage_test(window, cx)));
+ let bars = self.coverage_bars(file.statement, file.branch, file.declaration, false, false);
+ let row = div().flex().items_center().px(px(22.)).h(px(25.)).child(bars).child(div().flex().items_center().children(actions));
+ let shadow = self.theme.color("editorStickyScroll.shadow");
+ let widget = div()
+ .id("coverage-summary-widget")
+ .debug_selector(|| "coverage-summary-widget".into())
+ .absolute()
+ .top_0()
+ .left_0()
+ .w_full()
+ .font_family(".SystemUIFont")
+ .text_color(self.color("editor.foreground"))
+ .bg(self.color("editor.background"))
+ // testing.css: `box-shadow: var(--vscode-editorStickyScroll-shadow) 0 3px 2px -2px`; CSS blur 2px is sigma 1px.
+ .when_some(shadow, |widget, shadow| widget.shadow(vec![BoxShadow { color: shadow.into(), offset: point(px(0.), px(3.)), blur_radius: px(1.), spread_radius: px(-2.), inset: false }]))
+ .block_mouse_except_scroll()
+ .on_mouse_down(MouseButton::Right, cx.listener(|workbench, event: &MouseDownEvent, window, cx| {
+ let context = workbench.key_context(window);
+ let anchor = gpui::Bounds { origin: event.position, size: gpui::Size::default() };
+ workbench.show_context_menu(crate::menus::MenuId::StickyScrollContext, &context, anchor, Vec::new(), window, cx);
+ }))
+ .child(row);
+ Some(widget.into_any_element())
+ }
+
+ /// `rerunTest`: the coverage's run again, its Rerun disabled until that run completes.
+ fn rerun_coverage_test(&mut self, window: &mut Window, cx: &mut Context<Self>) {
+ let Some((result, _, _)) = self.selected_coverage() else { return };
+ let request = result.request.clone();
+ self.testing.coverage.toolbar_rerun = Some(self.run_resolved_tests(request, window, cx));
+ cx.notify();
+ }
+
+ /// An `ActionWithIcon`: `iconOnly` as a codicon `ActionViewItem`, else a `CodiconActionViewItem` of icon and label
+ /// (testing.css `.coverage-summary-widget .action-label`).
+ fn coverage_toolbar_action(&self, icon: &str, label: Option<&str>, tooltip: String, enabled: bool, cx: &mut Context<Self>, run: impl Fn(&mut Self, &mut Window, &mut Context<Self>) + 'static) -> AnyElement {
+ let color = if enabled { self.color("editor.foreground") } else { self.color("disabledForeground") };
+ let mut item = div().id(gpui::SharedString::from(format!("coverage-toolbar-{icon}"))).mx(px(3.)).px(px(4.)).flex().items_center().rounded(px(5.)).text_size(px(13.)).whitespace_nowrap();
+ item = match label {
+ Some(label) => item.child(self.icon(icon, 16., 16., color).mr(px(4.))).child(div().text_color(color).child(label.to_owned())),
+ None => item.child(self.icon(icon, 16., 16., color)),
+ };
+ let hover = self.hover_target(gpui::SharedString::from(format!("coverage-toolbar-hover-{icon}")), HoverContent::Text(tooltip), HoverOptions::action_item());
+ let item = item.child(hover);
+ if !enabled {
+ return item.into_any_element();
+ }
+ item.cursor_pointer()
+ .hover(|item| item.bg(self.color("toolbar.hoverBackground")))
+ .on_click(cx.listener(move |workbench, _: &ClickEvent, window, cx| {
+ cx.stop_propagation();
+ run(workbench, window, cx);
+ }))
+ .into_any_element()
+ }
+
+ /// `applyHoverOptions` holds for every range: `showInline`, or `hoverLineNumber` of the editor.
+ fn shows_inline_coverage(&self, model_id: u32) -> bool {
+ self.testing.coverage.show_inline || self.testing.coverage.hovered_line_numbers == Some(model_id)
+ }
+
+ /// The `countBadge` before each primary range (`id` its index) and the indicator after each missed branch.
+ fn coverage_injections(&self, ranges: &[InlineCoverage]) -> Vec<InjectedText> {
+ let font_size = super::editor_view::EDITOR_FONT_SIZE * self.editor_zoom.multiplier();
+ let char_width = self.editors.viewport.char_width;
+ let mut injections = Vec::new();
+ for (id, range) in ranges.iter().enumerate() {
+ if let Some(count) = &range.count {
+ // testing.css `.coverage-deco-inline-count`: 0.7em text with its 0.4em and 0.7em margins and 0.2em padding.
+ let columns = 0.7 * count.chars().count() as f32 + 0.7 * 1.3 * font_size / char_width;
+ let position = Position::new(range.start.0, range.start.1);
+ injections.push(InjectedText { position, columns, content: count.clone(), wrap: WrapWidth::Chars, owner: InjectionOwner::Coverage, id, at_range_start: true });
+ }
+ if range.branch_miss {
+ let position = Position::new(range.end.0, range.end.1);
+ injections.push(InjectedText { position, columns: 4., content: BRANCH_MISS_INDICATOR.into(), wrap: WrapWidth::Chars, owner: InjectionOwner::Coverage, id, at_range_start: false });
+ }
+ }
+ injections.sort_by_key(|injection| injection.position);
+ injections
+ }
+
+ /// The `coverage-deco-inline` boxes on model line `line`: the hit or miss fill with its 1px outline inset by
+ /// `outline-offset: -1px`, stronger on the hovered range (theme.ts `.coverage-deco-hovered`).
+ pub(super) fn coverage_inline_boxes(&self, editor: &OpenEditor, line: usize, layout: &LineLayout, char_width: f32) -> Vec<Div> {
+ if !self.shows_inline_coverage(editor.model_id) {
+ return Vec::new();
+ }
+ let Some(ranges) = self.testing.coverage.inline.get(&editor.model_id) else { return Vec::new() };
+ let line_length = editor.document().lines[line].chars().count();
+ let high_contrast = self.theme.kind.is_high_contrast();
+ let mut boxes = Vec::new();
+ for (index, range) in ranges.iter().enumerate().filter(|(_, range)| !range.branch_miss && range.start.0 <= line && line <= range.end.0) {
+ let from = if line == range.start.0 { range.start.1 } else { 0 };
+ let to = if line == range.end.0 { range.end.1 } else { line_length };
+ if from == to {
+ continue;
+ }
+ let (start, end) = layout.range(from, to);
+ let (background, border) = if range.hit { ("testing.coveredBackground", "testing.coveredBorder") } else { ("testing.uncoveredBackground", "testing.uncoveredBorder") };
+ let (mut background, mut border) = (self.theme.color(background), self.theme.color(border));
+ if self.testing.coverage.hovered_range == Some((editor.model_id, index)) {
+ background = background.map(|color| transparent(color, 1.3));
+ border = border.map(|color| transparent(color, 2.));
+ }
+ let mut area = div().absolute().top_0().bottom_0().left(px(start * char_width)).w(px((end - start) * char_width));
+ if let Some(background) = background {
+ area = area.bg(background);
+ }
+ if let Some(border) = border {
+ // testing.css: the high contrast outline of a hit is dashed.
+ area = area.border_1().border_color(border).when(high_contrast && range.hit, |area| area.border_dashed());
+ }
+ boxes.push(area.debug_selector(move || format!("coverage-inline-{line}-{index}")));
+ }
+ boxes
+ }
+
+ /// A `coverage-deco-inline-count` badge, or the `coverage-deco-branch-miss-indicator` with its `question` icon.
+ pub(super) fn coverage_injection_element(&self, content: &str, left: f32, line_height: f32) -> AnyElement {
+ let font_size = super::editor_view::EDITOR_FONT_SIZE * self.editor_zoom.multiplier();
+ let char_width = self.editors.viewport.char_width;
+ if content == BRANCH_MISS_INDICATOR {
+ let icon = self.icon("question", line_height / 2., line_height / 2., self.color("editor.foreground"));
+ let mut marker = div().p(px(line_height / 10.)).rounded(px(2.)).border_1().child(icon);
+ // theme.ts: no rule where the theme has no `testing.uncoveredBackground`.
+ if let Some(miss) = self.theme.color("testing.uncoveredBackground") {
+ let badge = crate::theme::make_opaque(transparent(miss, 2.), self.color("editor.background"));
+ marker = marker.border_color(transparent(badge, 1.3)).bg(badge);
+ }
+ let indicator = div().absolute().top_0().left(px(left)).w(px(4. * char_width)).h(px(line_height)).flex().items_center().justify_center().child(marker);
+ return indicator.debug_selector(|| "coverage-branch-miss".into()).into_any_element();
+ }
+ let (background, foreground) = (self.color("testing.coverCountBadgeBackground"), self.color("testing.coverCountBadgeForeground"));
+ let em = 0.7 * font_size;
+ let height = 1.2 * em + 0.4 * em;
+ let label = div().h(px(height)).pl(px(0.2 * em)).flex().items_center().rounded_l(px(2.)).bg(background).text_color(foreground).text_size(px(em)).child(content.to_owned());
+ // The `::after` arrow: two triangles of the badge color meeting at the middle of its right side.
+ let arrow = canvas(
+ |_, _, _| (),
+ move |bounds, _, window, _| {
+ let (x, y, size) = (bounds.origin.x, bounds.origin.y, bounds.size);
+ let mut path = PathBuilder::fill();
+ path.move_to(point(x, y));
+ path.line_to(point(x + size.width, y + size.height / 2.));
+ path.line_to(point(x, y + size.height));
+ path.close();
+ if let Ok(path) = path.build() {
+ window.paint_path(path, background);
+ }
+ },
+ )
+ .w(px(0.5 * em))
+ .h(px(height));
+ let badge = div().flex().child(label).child(arrow);
+ let row = div().absolute().top_0().left(px(left + 0.4 * em)).h(px(line_height)).flex().items_center().whitespace_nowrap().child(badge);
+ row.debug_selector(|| "coverage-count-badge".into()).into_any_element()
+ }
+
+ /// markdownHoverParticipant.ts `computeSync` over the shown ranges' `hoverMessage` (`describe`).
+ pub(super) fn coverage_hover_parts(&self, editor: &OpenEditor, anchor: Anchor) -> Vec<Part> {
+ if !self.shows_inline_coverage(editor.model_id) {
+ return Vec::new();
+ }
+ let Some(ranges) = self.testing.coverage.inline.get(&editor.model_id) else { return Vec::new() };
+ let Some(details) = self.file_coverage(&editor.document().uri()).and_then(|file| self.cached_coverage_details(&file)) else { return Vec::new() };
+ let lines = &editor.document().lines;
+ let mut parts = Vec::new();
+ for range in ranges.iter().filter(|range| range.start.0 <= anchor.line && anchor.line <= range.end.0) {
+ let from = if range.start.0 == anchor.line { range.start.1 } else { 0 };
+ let to = if range.end.0 == anchor.line { range.end.1 } else { lines[anchor.line].chars().count() };
+ if from > anchor.start || anchor.end > to {
+ continue;
+ }
+ let content = PartContent::Markdown(vec![json!({ "value": describe(details, range.detail, range.branch, lines) })]);
+ let (start, end) = (Position::new(range.start.0, range.start.1), Position::new(range.end.0, range.end.1));
+ parts.push(Part { participant: Participant::Markdown, ordinal: parts.len(), start, end, content, source: None });
+ }
+ parts
+ }
+
+ /// `onMouseMove` in the active editor: over its line numbers `hoverLineNumber`, over its text with `showInline`
+ /// `hoverInlineDecoration` of the first range touching `text` (line, model x), else neither.
+ pub(super) fn coverage_mouse_moved(&mut self, line_numbers: bool, text: Option<(usize, f32)>, cx: &mut Context<Self>) {
+ let model_id = self.editors.active().map_or(u32::MAX, |editor| editor.model_id);
+ let coverage = &self.testing.coverage;
+ let has_ranges = coverage.inline.get(&model_id).is_some_and(|ranges| !ranges.is_empty());
+ let hovered_line_numbers = (line_numbers && has_ranges && !coverage.show_inline).then_some(model_id);
+ let hovered_range = match text.filter(|_| coverage.show_inline && !line_numbers) {
+ Some((line, x)) => self.editors.active().and_then(|editor| {
+ let text = &editor.document().lines[line];
+ let column = LineLayout::new(text, editor.document().indentation.tab_size, std::iter::empty()).column_at(x);
+ let position = (line, column);
+ let ranges = coverage.inline.get(&model_id)?;
+ ranges.iter().position(|range| range.start <= position && position <= range.end).map(|index| (model_id, index))
+ }),
+ None => None,
+ };
+ if (hovered_line_numbers, hovered_range) != (coverage.hovered_line_numbers, coverage.hovered_range) {
+ self.testing.coverage.hovered_line_numbers = hovered_line_numbers;
+ self.testing.coverage.hovered_range = hovered_range;
+ cx.notify();
+ }
+ }
+}
+
+/// color.ts `transparent`: the alpha times `factor`.
+fn transparent(color: Rgba, factor: f32) -> Rgba {
+ Rgba { a: (color.a * factor).min(1.), ..color }
+}
diff --git a/native/crates/app/src/workbench/editor_view.rs b/native/crates/app/src/workbench/editor_view.rs
index 6046cb3cafe..60c2a2fefae 100644
--- a/native/crates/app/src/workbench/editor_view.rs
+++ b/native/crates/app/src/workbench/editor_view.rs
@@ -441,8 +441,14 @@ impl Workbench {
navigation.sort_by(|a, b| crate::command_palette::locale_compare(&a.title, &b.title));
for item in navigation {
match &item.entry {
- crate::menus::Entry::Command { id, .. } => {
- let button = self.command_button(id, item.title.clone(), resource.clone(), foreground, cx);
+ crate::menus::Entry::Command { id, toggled, .. } => {
+ // menuEntryActionViewItem.ts: a checked item shows its toggled title and icon, on `actionBar.toggledBackground`.
+ let toggled = toggled.as_ref().filter(|toggled| toggled.condition.evaluate(&context));
+ let title = toggled.and_then(|toggled| toggled.title.clone()).unwrap_or_else(|| item.title.clone());
+ let toggled_icon = toggled.and_then(|toggled| toggled.icon.clone()).map(crate::menus::CommandIcon::Codicon);
+ let icon = toggled_icon.as_ref().or(self.command_icons.get(id));
+ let toggled_background = self.theme.color("actionBar.toggledBackground").unwrap_or(self.color("inputOption.activeBackground"));
+ let button = self.command_button_with_icon(id, icon, title, resource.clone(), foreground, cx).when(toggled.is_some(), |button| button.bg(toggled_background));
actions.push((item.order, self.title_action(bar, &actions.len().to_string(), button, cx)));
}
// layoutActions.ts: the only workbench submenu here, with its `Codicon.gear` icon.
@@ -1289,12 +1295,15 @@ impl Workbench {
workbench.content_hover_mouse_left(window.mouse_position(), window, cx);
workbench.definition_link_mouse_left();
workbench.commenting_hover_moved(None, cx);
+ workbench.coverage_mouse_moved(false, None, cx);
}
}
}))
// The line's row sets `row_target` first: moves bubble from the row up to the text area.
.on_mouse_move(cx.listener(|workbench, event: &MouseMoveEvent, window, cx| {
let row_target = workbench.content_hover.row_target.take();
+ let line_numbers = workbench.testing.coverage.line_numbers_target.take().is_some_and(|model_id| workbench.row_editor_active(model_id));
+ workbench.coverage_mouse_moved(line_numbers, row_target, cx);
workbench.links_mouse_moved(row_target, event.modifiers, cx);
let target = match row_target {
Some((line, visible)) => super::content_hover::MouseTarget::Text { line, visible },
@@ -1440,6 +1449,8 @@ impl Workbench {
)
.when(editor.scroll.top > 0. && !in_multi_diff, |area| area.child(div().absolute().top_0().left_0().right(px(VERTICAL_SCROLLBAR_WIDTH)).h(px(SCROLL_SHADOW_HEIGHT)).cursor_default().child(self.scroll_shadow().size_full())))
// minimap.css: the sticky scroll and the minimap share z-index 4, so the minimap, later in the DOM, paints over it.
+ // testing.css: the coverage toolbar's z-index 1 is under the sticky scroll and the minimap.
+ .children(self.coverage_toolbar(editor, window, cx))
.child(shifted().children(self.sticky_scroll_widget(editor, metrics, window, cx)))
.children(self.minimap(editor, cx))
.child(
@@ -1957,6 +1968,7 @@ impl Workbench {
.when(metrics.line_numbers == LineNumbers::Relative && index == primary_line, |number| number.text_left())
// testing.css `.coverage-deco-gutter::before`: the fill sits under the number.
.when_some(coverage.get(&index).and_then(|line| self.coverage_gutter(*line)), |number, gutter| number.relative().child(gutter))
+ .on_mouse_move(cx.listener(move |workbench, _: &MouseMoveEvent, _, _| workbench.testing.coverage.line_numbers_target = Some(model_id)))
.children(line_number_label(metrics.line_numbers, index, primary_line, editor.document().lines.len()).filter(|_| segment.first));
let mut current_line = div().absolute().inset_0();
if line_highlight && all_empty && (0..selections.len()).any(|cursor_index| editor.head_view_line(cursor_index) == view_line) {
@@ -2072,6 +2084,7 @@ impl Workbench {
content = content.children(self.diff_line_decorations(editor, index, char_width, scroll_left));
content = content.children(self.merge_line_decorations(editor, index, char_width, scroll_left));
content = content.children(self.text_decoration_boxes(editor, index, scroll_left, &layout, char_width));
+ content = content.children(self.coverage_inline_boxes(editor, index, &layout, char_width));
content = content.children(self.search_editor_line_decorations(editor, index, char_width));
// anchorSelect.css: `.selection-anchor` is a 2px #007ACC bar in every theme, under the word highlights.
if let Some(anchor) = editor.selection_anchor
diff --git a/native/crates/app/src/workbench/editor_view/injected_text_view.rs b/native/crates/app/src/workbench/editor_view/injected_text_view.rs
index 760620fb497..88b0da79bf0 100644
--- a/native/crates/app/src/workbench/editor_view/injected_text_view.rs
+++ b/native/crates/app/src/workbench/editor_view/injected_text_view.rs
@@ -71,6 +71,7 @@ impl Workbench {
InjectionOwner::InlineProgress => None,
InjectionOwner::DebugInlineValue => Some(self.debug_inline_value_element(&injection.content, left, metrics.line_height)),
InjectionOwner::StackFrameColumn => Some(self.stack_frame_column_element(injection.id == 1, left, metrics.line_height)),
+ InjectionOwner::Coverage => Some(self.coverage_injection_element(&injection.content, left, metrics.line_height)),
InjectionOwner::InlineBreakpoint => {
// The widget sits at the column before its decoration's (`getPosition`).
let anchor = injection.position.column.checked_sub(1).map(|column| layout.char_x(column) * metrics.char_width);
diff --git a/native/crates/app/src/workbench/keyboard.rs b/native/crates/app/src/workbench/keyboard.rs
index 3d1168e6059..352622eb292 100644
--- a/native/crates/app/src/workbench/keyboard.rs
+++ b/native/crates/app/src/workbench/keyboard.rs
@@ -511,7 +511,8 @@ impl Workbench {
super::welcome_page::WALKTHROUGH_SCHEME => "gettingStartedPage",
super::disassembly_view::DISASSEMBLY_SCHEME => "workbench.debug.disassemblyView",
_ if self.active_notebook_editor().is_some() => "workbench.editor.notebook",
- _ => "workbench.editor.files",
+ // textfiles.ts `TEXT_FILE_EDITOR_ID`.
+ _ => "workbench.editors.files.textFileEditor",
};
context.insert("activeEditor".into(), json!(pane));
// contextkeys.ts `applyAvailableEditorIds`; every use reads it as a boolean, so the showing editor's id stands in for the list.
diff --git a/native/crates/app/src/workbench/scm_view.rs b/native/crates/app/src/workbench/scm_view.rs
index 849d8988550..7482bfc9b39 100644
--- a/native/crates/app/src/workbench/scm_view.rs
+++ b/native/crates/app/src/workbench/scm_view.rs
@@ -1194,7 +1194,11 @@ impl Workbench {
/// A menu command as a toolbar button (`MenuEntryActionViewItem`): its icon, else its title, with its hover.
pub(in crate::workbench) fn command_button(&self, id: &str, title: String, args: Vec<Value>, foreground: Rgba, cx: &mut Context<Self>) -> gpui::Stateful<Div> {
- let icon = self.command_icon(self.command_icons.get(id), &title, foreground);
+ self.command_button_with_icon(id, self.command_icons.get(id), title, args, foreground, cx)
+ }
+
+ pub(in crate::workbench) fn command_button_with_icon(&self, id: &str, icon: Option<&crate::menus::CommandIcon>, title: String, args: Vec<Value>, foreground: Rgba, cx: &mut Context<Self>) -> gpui::Stateful<Div> {
+ let icon = self.command_icon(icon, &title, foreground);
let command = id.to_string();
icon.id(gpui::SharedString::from(format!("command-button-{id}-{}", args.first().map(Value::to_string).unwrap_or_default())))
.rounded(px(4.))
diff --git a/native/crates/app/src/workbench/testing_coverage_view.rs b/native/crates/app/src/workbench/testing_coverage_view.rs
index e2a4e00cd91..72ca2ad310a 100644
--- a/native/crates/app/src/workbench/testing_coverage_view.rs
+++ b/native/crates/app/src/workbench/testing_coverage_view.rs
@@ -12,7 +12,7 @@ use crate::commands::Outcome;
use crate::main_thread_quick_open::Owner;
use crate::quick_input::{Entry, Item, Kind, QuickInput};
use crate::testing::{RunTask, TestResult, parent_id};
-use crate::testing_coverage::{CoverageCount, CoverageDetail, CoverageNode, CoverageUri, DeclarationNode, DetailType, FileCoverage, SerializedFileCoverage, TestCoverage, coverage_color, declaration_tree, detail_ranges, display_percent, displayed_stat, total_coverage_percent};
+use crate::testing_coverage::{CoverageCount, CoverageDetail, CoverageNode, CoverageUri, DeclarationNode, FileCoverage, InlineCoverage, SerializedFileCoverage, TestCoverage, coverage_color, declaration_tree, detail_ranges, display_percent, displayed_stat, total_coverage_percent};
#[cfg(test)]
mod tests;
@@ -28,6 +28,20 @@ pub struct CoverageService {
pub selected: Option<(String, String)>,
/// `filterToTest`.
pub filter_to_test: Option<String>,
+ /// `showInline`.
+ pub show_inline: bool,
+ /// codeCoverageDecorations.ts `hoveredSubject` `lineNo`: the editor whose line numbers the mouse is over, which
+ /// shows its inline coverage; `line_numbers_target` is set by a line number's move before the editor's.
+ pub hovered_line_numbers: Option<u32>,
+ pub line_numbers_target: Option<u32>,
+ /// `hoveredSubject` of a range with `showInline`: the editor's model id and the range's index in `inline`.
+ pub hovered_range: Option<(u32, usize)>,
+ /// The inline coverage of each editor's file, by model id, as `sync_inline_coverage` last made it.
+ pub inline: HashMap<u32, Vec<InlineCoverage>>,
+ /// The `CoverageToolbarWidget` view zone of each editor that shows the toolbar, by model id.
+ pub toolbar_zones: HashMap<u32, u32>,
+ /// The toolbar's Rerun run while it is not complete (`isRunning`).
+ pub toolbar_rerun: Option<String>,
/// The view's `CoverageSortOrder`, stored as `testing.coverageSortOrder`.
pub sort_order: SortOrder,
/// The view's rows flipped from their default collapse state, and its selected row, by URI.
@@ -89,7 +103,21 @@ impl Workbench {
Outcome::done()
});
self.commands.register("testing.coverageFilterToTest", |workbench, _, window, cx| {
- workbench.pick_coverage_test(window, cx);
+ let tests = workbench.selected_coverage().map(|(_, _, coverage)| coverage.all_per_test_ids()).unwrap_or_default();
+ workbench.pick_coverage_test(tests, window, cx);
+ Outcome::done()
+ });
+ // codeCoverageDecorations.ts `FilterCoverageToTestInEditor`: the tests of the active editor's file.
+ self.commands.register("testing.coverageFilterToTestInEditor", |workbench, _, window, cx| {
+ let file = workbench.editors.active().and_then(|editor| workbench.file_coverage(&editor.document().uri()));
+ if let Some(file) = file.filter(|file| !file.per_test.is_empty()) {
+ workbench.pick_coverage_test(file.per_test.into_iter().collect(), window, cx);
+ }
+ Outcome::done()
+ });
+ self.commands.register("testing.toggleInlineCoverage", |workbench, _, _, cx| {
+ workbench.testing.coverage.show_inline = !workbench.testing.coverage.show_inline;
+ cx.notify();
Outcome::done()
});
self.commands.register("testing.coverageViewChangeSorting", |workbench, _, window, cx| {
@@ -181,7 +209,8 @@ impl Workbench {
("testing.hasPerTestCoverage", per_test),
("testing.isCoverageFilteredToTest", self.testing.coverage.filter_to_test.is_some()),
("testing.hasCoverageInFile", file.is_some()),
- ("testing.inlineCoverageEnabled", false),
+ ("testing.inlineCoverageEnabled", self.testing.coverage.show_inline),
+ ("testing.hasInlineCoverageDetails", self.editors.active().is_some_and(|editor| self.testing.coverage.inline.get(&editor.model_id).is_some_and(|ranges| !ranges.is_empty()))),
("testing.coverageToolbarEnabled", self.setting("testing.coverageToolbarEnabled") != false),
] {
context.insert(key.to_owned(), json!(value));
@@ -189,15 +218,14 @@ impl Workbench {
}
/// `report.getUri` of the opened coverage for an editor's document URI.
- fn file_coverage(&self, uri: &Value) -> Option<FileCoverage> {
+ pub(super) fn file_coverage(&self, uri: &Value) -> Option<FileCoverage> {
let (_, _, coverage) = self.selected_coverage()?;
coverage.file(&CoverageUri::from_value(uri)).cloned()
}
- /// `TestCoverageChangePerTestFilterAction`: "Entire run", then each test with per-test data.
- fn pick_coverage_test(&mut self, window: &mut Window, cx: &mut Context<Self>) {
- let Some((result, _, coverage)) = self.selected_coverage() else { return };
- let tests = coverage.all_per_test_ids();
+ /// `TestCoverageChangePerTestFilterAction`: "Entire run", then each of `tests`.
+ fn pick_coverage_test(&mut self, tests: Vec<String>, window: &mut Window, cx: &mut Context<Self>) {
+ let Some((result, _, _)) = self.selected_coverage() else { return };
let common_prefix = common_prefix_length(&tests);
let mut entries = vec![Entry::Item(Item { handle: 0, label: "Entire run".into(), ..Item::default() }), Entry::Separator(None)];
for (index, test) in tests.iter().enumerate() {
@@ -420,13 +448,13 @@ impl Workbench {
true => self.icon("check", 16., 16., foreground),
false => self.icon("circle-outline", 16., 16., self.color("testing.iconUnset")),
};
- let bars = declaration.attributable.map(|(statement, branch)| self.coverage_bars(statement, Some(branch), None, false));
+ let bars = declaration.attributable.map(|(statement, branch)| self.coverage_bars(statement, Some(branch), None, false, true));
let location = declaration.detail.location;
let end = if declaration.detail.position { location.start } else { location.end };
let selection = json!({ "startLineNumber": location.start.line, "startColumn": location.start.column, "endLineNumber": end.line, "endColumn": end.column });
(Some(icon), bars, json!({ "selection": selection, "selectionRevealType": 3 }))
}
- None => (None, (file.kind != crate::testing_coverage::CoverageKind::Bypassed).then(|| self.coverage_bars(file.statement, file.branch, file.declaration, false)), Value::Null),
+ None => (None, (file.kind != crate::testing_coverage::CoverageKind::Bypassed).then(|| self.coverage_bars(file.statement, file.branch, file.declaration, false, true)), Value::Null),
};
let open = (!row.folder).then(|| file.uri.clone());
element.child(twistie).children(icon).child(label).children(bars).on_click(cx.listener(move |workbench, _: &ClickEvent, window, cx| {
@@ -442,14 +470,15 @@ impl Workbench {
}
/// testCoverageBars.ts `ManagedTestCoverageBars`: the displayed percent at precision 2, then the statement, function
- /// and branch bars, or `compact` at precision 0 and one bar of the percent (testing.css `.test-coverage-bars`).
- fn coverage_bars(&self, statement: CoverageCount, branch: Option<CoverageCount>, declaration: Option<CoverageCount>, compact: bool) -> Div {
+ /// and branch bars, or `compact` at precision 0 and one bar of the percent (testing.css `.test-coverage-bars`); the
+ /// percent hidden without `overall_shown` (`overall: false`).
+ pub(super) fn coverage_bars(&self, statement: CoverageCount, branch: Option<CoverageCount>, declaration: Option<CoverageCount>, compact: bool, overall_shown: bool) -> Div {
let thresholds = self.setting("testing.coverageBarThresholds");
let method = self.setting("testing.displayedCoveragePercent");
let overall_stat = displayed_stat(statement, branch, declaration, method.as_str().unwrap_or("totalCoverage"));
let overall = display_percent(overall_stat, if compact { 0 } else { 2 });
let selector = format!("test-coverage-bars:{overall}");
- let mut bars = div().flex().flex_none().items_center().gap(px(4.)).text_size(px(11.)).mr(px(12.)).debug_selector(move || selector).child(overall);
+ let mut bars = div().flex().flex_none().items_center().gap(px(4.)).text_size(px(11.)).mr(px(12.)).debug_selector(move || selector).when(overall_shown, |bars| bars.child(overall));
if compact {
return bars.child(self.coverage_bar(overall_stat, false, &thresholds));
}
@@ -467,7 +496,7 @@ impl Workbench {
}
let (_, _, coverage) = self.selected_coverage()?;
let file = coverage.computed_for_uri(&CoverageUri::file(&path.to_string_lossy()))?;
- Some(self.coverage_bars(file.statement, file.branch, file.declaration, true))
+ Some(self.coverage_bars(file.statement, file.branch, file.declaration, true, true))
}
/// `renderBar`: 16px wide, filled to the floored percent, in the threshold's chart color or half the foreground
@@ -541,7 +570,7 @@ impl Workbench {
}
/// The opened coverage's details of a file for the test filter, loaded on first ask.
- fn coverage_details(&self, file: &FileCoverage, cx: &mut Context<Self>) -> Option<&[CoverageDetail]> {
+ pub(super) fn coverage_details(&self, file: &FileCoverage, cx: &mut Context<Self>) -> Option<&[CoverageDetail]> {
let (_, _, coverage) = self.selected_coverage()?;
let key = (file.uri.clone(), self.testing.coverage.filter_to_test.clone());
if !coverage.details.contains_key(&key) {
@@ -552,7 +581,7 @@ impl Workbench {
}
/// The opened coverage's loaded details of a file for the test filter.
- fn cached_coverage_details(&self, file: &FileCoverage) -> Option<&[CoverageDetail]> {
+ pub(super) fn cached_coverage_details(&self, file: &FileCoverage) -> Option<&[CoverageDetail]> {
let (_, _, coverage) = self.selected_coverage()?;
coverage.details.get(&(file.uri.clone(), self.testing.coverage.filter_to_test.clone()))?.as_deref()
}
diff --git a/native/crates/app/src/workbench/testing_coverage_view/tests.rs b/native/crates/app/src/workbench/testing_coverage_view/tests.rs
index 300601a168d..8ead81fff54 100644
--- a/native/crates/app/src/workbench/testing_coverage_view/tests.rs
+++ b/native/crates/app/src/workbench/testing_coverage_view/tests.rs
@@ -247,6 +247,115 @@ fn the_editor_title_goes_to_the_next_and_previous_uncovered_line(cx: &mut TestAp
assert_eq!(cursor_lines, vec![(2, 0), (0, 0), (2, 0), (0, 0)]);
}
+/// Coverage open on the test file: line 1's statement hit twice, line 3's missed.
+fn open_inline_details(workbench: &mut Workbench, window: &mut gpui::Window, cx: &mut gpui::Context<Workbench>) {
+ workbench.command_icons = crate::menus::command_icons(&[]);
+ add_result(workbench);
+ let uri = workbench.editors.active().expect("the test file").document().uri();
+ let coverage = json!({ "id": "f1", "uri": uri, "statement": { "covered": 1, "total": 2 } });
+ drop(workbench.handle_testing_request(request("$appendCoverage", vec![json!("r1"), json!("t1"), coverage]), window, cx));
+ workbench.open_coverage("r1", 0, false, cx);
+ let range = |line: u32| json!({ "startLineNumber": line, "startColumn": 1, "endLineNumber": line, "endColumn": 10 });
+ let details = vec![json!({ "type": 1, "count": 2, "location": range(1) }), json!({ "type": 1, "count": 0, "location": range(3) })];
+ let file = workbench.selected_coverage().expect("open").2.file(&crate::testing_coverage::CoverageUri::from_value(&uri)).expect("the file").clone();
+ let details = details.iter().filter_map(crate::testing_coverage::CoverageDetail::from_value).collect();
+ workbench.testing.results[0].tasks[0].coverage.as_mut().expect("coverage").details.insert((file.uri, None), Some(details));
+}
+
+/// codeCoverageDecorations.ts `CoverageToolbarWidget`: `testing.coverageToolbarEnabled` puts the file's bars and actions
+/// across the editor's top over a 30px zone above the first line, Show Inline turns inline coverage on, and the
+/// editor title's Toggle Inline Coverage gives way to it; turning the toolbar off removes both.
+#[gpui::test]
+fn the_coverage_toolbar_shows_the_files_coverage_and_toggles_inline(cx: &mut TestAppContext) {
+ let (workbench, cx, _host) = workbench_with_tests("coverage-toolbar", TESTS, cx);
+ let user = std::env::temp_dir().join(format!("vsrustium-coverage-toolbar-user-{}", std::process::id()));
+ workbench.update_in(cx, |workbench, window, cx| {
+ workbench.settings = std::sync::Arc::new(std::sync::Mutex::new(config::service::Settings::load(config::registry::Registry::with_extensions(&[]), user.clone(), None)));
+ open_inline_details(workbench, window, cx);
+ });
+ let draw = |cx: &mut gpui::VisualTestContext| {
+ cx.run_until_parked();
+ cx.update(|window, cx| drop(window.draw(cx)));
+ };
+ let zones = |workbench: &gpui::Entity<Workbench>, cx: &mut gpui::VisualTestContext| workbench.read_with(cx, |workbench, _| workbench.editors.active().expect("the test file").view_zones.iter().map(|zone| (zone.anchor, zone.height)).collect::<Vec<_>>());
+ draw(cx);
+ assert!(cx.debug_bounds("coverage-summary-widget").is_none(), "off by default");
+ workbench.update(cx, |workbench, cx| {
+ workbench.settings.lock().unwrap().update_value_derived("testing.coverageToolbarEnabled", Some(&json!(true))).unwrap();
+ cx.notify();
+ });
+ draw(cx);
+ assert!(cx.debug_bounds("coverage-summary-widget").is_some(), "shown by Show Test Coverage Toolbar");
+ assert_eq!(zones(&workbench, cx), vec![(None, 30.)]);
+ assert!(cx.debug_bounds("test-coverage-bars:50.00%").is_some(), "the file's bars");
+ assert!(cx.debug_bounds("codicon-coverage").is_some() && cx.debug_bounds("codicon-debug-rerun").is_some(), "Show Inline and Rerun");
+ let show_inline = cx.debug_bounds("codicon-coverage").expect("Show Inline").center();
+ cx.simulate_click(show_inline, gpui::Modifiers::none());
+ draw(cx);
+ assert!(workbench.read_with(cx, |workbench, _| workbench.testing.coverage.show_inline), "Show Inline turns inline coverage on");
+ assert!(cx.debug_bounds("coverage-count-badge").is_some());
+ workbench.update(cx, |workbench, cx| {
+ workbench.settings.lock().unwrap().update_value_derived("testing.coverageToolbarEnabled", Some(&json!(false))).unwrap();
+ cx.notify();
+ });
+ draw(cx);
+ assert!(cx.debug_bounds("coverage-summary-widget").is_none(), "hidden once turned off");
+ assert_eq!(zones(&workbench, cx), vec![]);
+ std::fs::remove_dir_all(user).unwrap();
+}
+
+/// codeCoverageDecorations.ts: with inline details the editor title shows Toggle Inline Coverage; the inline ranges
+/// and the `countBadge` of a hit draw while the mouse is over the line numbers (`hoverLineNumber`) or once the
+/// command turns inline coverage on, which also gives each range its `describe` hover.
+#[gpui::test]
+fn inline_coverage_shows_on_line_number_hover_and_with_toggle_inline_coverage(cx: &mut TestAppContext) {
+ let (workbench, cx, _host) = workbench_with_tests("coverage-inline", TESTS, cx);
+ workbench.update_in(cx, open_inline_details);
+ let draw = |cx: &mut gpui::VisualTestContext| {
+ cx.run_until_parked();
+ cx.update(|window, cx| drop(window.draw(cx)));
+ };
+ draw(cx);
+ assert!(cx.debug_bounds("codicon-coverage").is_some(), "Toggle Inline Coverage in the editor title");
+ assert!(cx.debug_bounds("coverage-count-badge").is_none(), "no inline coverage by default");
+ workbench.update(cx, |workbench, cx| workbench.coverage_mouse_moved(true, None, cx));
+ draw(cx);
+ assert!(cx.debug_bounds("coverage-count-badge").is_some(), "shown while over the line numbers");
+ workbench.update(cx, |workbench, cx| workbench.coverage_mouse_moved(false, None, cx));
+ draw(cx);
+ assert!(cx.debug_bounds("coverage-count-badge").is_none(), "hidden once the mouse leaves them");
+ let (enabled, hover) = workbench.update_in(cx, |workbench, window, cx| {
+ drop(workbench.execute_command("testing.toggleInlineCoverage", Vec::new(), window, cx));
+ let editor = workbench.editors.active().expect("the test file");
+ let anchor = crate::workbench::content_hover::Anchor { model_id: editor.model_id, line: 0, start: 2, end: 3 };
+ let hover: Vec<_> = workbench.coverage_hover_parts(editor, anchor).into_iter().filter_map(|part| match part.content {
+ crate::workbench::content_hover::PartContent::Markdown(markdown) => Some(markdown),
+ _ => None,
+ }).collect();
+ (workbench.key_context(window)["testing.inlineCoverageEnabled"] == true, hover)
+ });
+ draw(cx);
+ assert!(enabled);
+ assert!(cx.debug_bounds("coverage-count-badge").is_some(), "shown by Toggle Inline Coverage");
+ assert!(cx.debug_bounds("coverage-inline-0-0").is_some() && cx.debug_bounds("coverage-inline-2-1").is_some(), "the hit and the missed range");
+ assert_eq!(hover, vec![vec![json!({ "value": "``test('t',`` was executed 2 time(s)." })]]);
+ // FilterCoverageToTestInEditor: with per-test data the title shows `filter`, filtered to a test its toggled `filter-filled`.
+ assert!(cx.debug_bounds("codicon-filter").is_none(), "no per-test data yet");
+ workbench.update_in(cx, |workbench, window, cx| {
+ let uri = workbench.editors.active().expect("the test file").document().uri();
+ let coverage = json!({ "id": "f1", "uri": uri, "statement": { "covered": 1, "total": 2 }, "testIds": ["c\0f\0a"] });
+ drop(workbench.handle_testing_request(request("$appendCoverage", vec![json!("r1"), json!("t1"), coverage]), window, cx));
+ });
+ draw(cx);
+ assert!(cx.debug_bounds("codicon-filter").is_some(), "Filter Coverage to Test");
+ workbench.update(cx, |workbench, cx| {
+ workbench.testing.coverage.filter_to_test = Some("c\0f\0a".into());
+ cx.notify();
+ });
+ draw(cx);
+ assert!(cx.debug_bounds("codicon-filter-filled").is_some() && cx.debug_bounds("codicon-filter").is_none(), "the toggled icon");
+}
+
/// testing.css `.hc-black .coverage-deco-gutter::before`: in high contrast a covered or missed line number is outlined
/// 3px above and below and 5px on the left, without a fill.
#[gpui::test]
diff --git a/native/crates/app/src/workbench/testing_item_menu.rs b/native/crates/app/src/workbench/testing_item_menu.rs
index e667f1b956b..3b4dab93756 100644
--- a/native/crates/app/src/workbench/testing_item_menu.rs
+++ b/native/crates/app/src/workbench/testing_item_menu.rs
@@ -110,7 +110,7 @@ impl Workbench {
add("testing.run", "Run Test", group, 11., "testing.hasRunnableTests", None, None);
add("testing.debug", "Debug Test", group, 12., "testing.hasDebuggableTests", None, None);
add("testing.coverage", "Run Test with Coverage", group, 13., "testing.hasCoverableTests", None, None);
- let off = Toggled { condition: Expr::deserialize("testing.isContinuousModeOn").expect("a valid expression"), title: Some("Turn off Continuous Run".to_owned()) };
+ let off = Toggled { condition: Expr::deserialize("testing.isContinuousModeOn").expect("a valid expression"), title: Some("Turn off Continuous Run".to_owned()), icon: None };
add("testing.toggleContinuousRunForTest", "Turn on Continuous Run", group, f64::from(i32::MAX), "testing.supportsContinuousRun", Some("testing.isContinuousModeOn || !testing.isParentRunningContinuously"), Some(off));
}
add("testing.continuousRunUsingForTest", "Start Continous Run Using...", "builtin@2", 14., "testing.supportsContinuousRun && !testing.isContinuousModeOn", None, None);
diff --git a/port/fixtures/ui-pair/m16/breakpoint.json b/port/fixtures/ui-pair/m16/breakpoint.json
new file mode 100644
index 00000000000..76a18714e58
--- /dev/null
+++ b/port/fixtures/ui-pair/m16/breakpoint.json
@@ -0,0 +1,29 @@
+[
+ { "wait": 10000 },
+ { "hotkey": ["cmd", "p"], "foreground": true },
+ { "wait": 800 },
+ { "type": ":5" },
+ { "wait": 800 },
+ { "key": "return" },
+ { "wait": 800 },
+ { "hotkey": ["cmd", "shift", "p"], "foreground": true },
+ { "wait": 800 },
+ { "type": "Debug: Toggle Breakpoint" },
+ { "wait": 800 },
+ { "key": "return" },
+ { "wait": 800 },
+ { "hotkey": ["cmd", "shift", "p"], "foreground": true },
+ { "wait": 800 },
+ { "type": "Debug: Select and Start Debugging" },
+ { "wait": 800 },
+ { "key": "return" },
+ { "wait": 1500 },
+ { "type": "Launch app.js" },
+ { "wait": 800 },
+ { "key": "return" },
+ { "wait": 10000 },
+ { "shot": "stopped" },
+ { "click": [115, 107] },
+ { "wait": 2000 },
+ { "shot": "locals" }
+]
diff --git a/port/fixtures/ui-pair/m16/inline-coverage.json b/port/fixtures/ui-pair/m16/inline-coverage.json
new file mode 100644
index 00000000000..55fa80a7a31
--- /dev/null
+++ b/port/fixtures/ui-pair/m16/inline-coverage.json
@@ -0,0 +1,24 @@
+[
+ { "wait": 12000 },
+ { "hotkey": ["cmd", "shift", "p"], "foreground": true },
+ { "wait": 800 },
+ { "type": "Run All Tests with Coverage" },
+ { "wait": 800 },
+ { "key": "return" },
+ { "wait": 6000 },
+ { "shot": "title-actions" },
+ { "hotkey": ["cmd", "shift", "p"], "foreground": true },
+ { "wait": 800 },
+ { "type": "Toggle Inline Coverage" },
+ { "wait": 800 },
+ { "key": "return" },
+ { "wait": 1500 },
+ { "shot": "inline" },
+ { "hotkey": ["cmd", "shift", "p"], "foreground": true },
+ { "wait": 800 },
+ { "type": "Show Test Coverage Toolbar" },
+ { "wait": 800 },
+ { "key": "return" },
+ { "wait": 1500 },
+ { "shot": "toolbar" }
+]
diff --git a/port/ledger.md b/port/ledger.md
index c9fb6a59eaf..4a941d6b0eb 100644
--- a/port/ledger.md
+++ b/port/ledger.md
@@ -33,11 +33,11 @@ Status: `open`, `in progress`, `waiting on Artur`, `later` (postponed), `done`,
| Milestones | M13 language features | done | Everything `MainThreadLanguageFeatures` registers, drawn by the native editor: completion, hover, signature help, code actions and lightbulb, code lens, inlay hints, go to definition and peek, references, rename, formatting, document symbols and Outline, semantic tokens, semantic word highlight, links, color picker, linked editing, snippets, call and type hierarchy, inline completions from extensions; diagnostics with squiggles and the Problems panel; comments threads; Emmet; the language status item. Open gaps: the gaps column of its unit rows. | api-tests `languages.test`, `languagefeatures.test`-family and `comments` cases pass as in the reference; with `src/main.ts` open TypeScript completion, hover, go to definition and a diagnostic squiggle work (pixel-check window with a squiggle and the suggest widget). |
| Milestones | M14 source control and diff | done | SCM view and input box, quick diff gutter, the diff editor (side by side and inline), multi-file diff, merge editor and merge-conflict decorations, timeline, the git, git-base and github extensions fully working (no sign-in: github features that need a token stay off). Open gaps: the gaps column of its unit rows. | api-tests SCM cases pass as in the reference; with the fixture copied into a git repository the SCM view lists a changed file and opening it shows the diff (pixel-check window). |
| Milestones | M15 terminal, tasks, output | done | Integrated terminal (PTY from Rust, VT parser and renderer in GPUI), shell integration, extension terminals and pseudoterminals, tasks and problem matchers, npm/grunt/gulp/jake task providers, external terminal, Output panel and log viewer. Open gaps: the gaps column of its unit rows. | api-tests `terminal.test`, `terminal.shellIntegration.test` and `workspace.tasks.test` pass as in the reference (run with `SHELL=/bin/bash` as the baseline was); `npm: build` task from the fixture runs in a terminal. |
-| Milestones | M16 debug and testing | in progress | Debug adapter protocol client, launch.json, breakpoints in the gutter, call stack, variables, watch, debug console, JS debugger (`ms-vscode.js-debug`), Test Explorer and test results. Open gaps: the gaps column of its unit rows. | api-tests `debug.test` and testing cases pass as in the reference; a breakpoint in a Node script from the fixture stops and shows variables. |
+| Milestones | M16 debug and testing | done | Debug adapter protocol client, launch.json, breakpoints in the gutter, call stack, variables, watch, debug console, JS debugger (`ms-vscode.js-debug`), Test Explorer and test results. Open gaps: the gaps column of its unit rows. Done-when check: `MOCHA_GREP="vscode API - debug|createTestController" port/tools/api-tests` gives api-folder 4 passing, 2 pending (upstream `test.skip`), 0 failing, as the reference; ui-pair port/fixtures/ui-pair/m16/breakpoint.json on port/fixtures/debug-node: Launch app.js stops at the line 5 breakpoint and Local: main shows `greeting`, `numbers`, `this` and `total = 6`, as the reference. | api-tests `debug.test` and testing cases pass as in the reference; a breakpoint in a Node script from the fixture stops and shows variables. |
| Milestones | M17 webviews and notebooks | done | A WKWebView embedded in the GPUI window for webview panels, webview views and custom editors, with the upstream message and resource protocol; Markdown preview, image/media preview, simple browser, editor insets; notebooks (ipynb) with renderers and kernels. Open gaps: the gaps column of its unit rows. | api-tests `webview.test`, `customEditor` and `notebook*.test` cases pass as in the reference; Markdown preview of the fixture README draws next to its source. |
| Milestones | M18 extensions: install, update, gallery | done | Extensions view backed by Open VSX, install/uninstall/update/disable, VSIX install, signature and checksum checks, recommendations, ESM extensions added after startup on Bun, language packs and display language. | Installing an extension from Open VSX activates it without restart (an ESM one included); api-tests `extensions.test` pass as in the reference. PORT_GALLERY=1 port/tools/extensions-check: 6 ok; MOCHA_GREP="vscode server cli" port/tools/api-tests: its one test pending, as in the reference (remote only). |
| Milestones | M19 product shell, privacy, accessibility, release | done | Welcome page and walkthroughs, update channel for the port's own builds, relaunch, splash, accessibility (VoiceOver through GPUI's accessibility tree, accessibility signals, high-contrast checks), process explorer and performance views, telemetry inert end to end, packaged and signed `.app`. Open gaps: the gaps column of its unit rows. | The telemetry source search (no telemetry endpoint string reachable) and network capture (zero outbound requests in a 10 min session with no user action) pass; VoiceOver reads the editor line and the Explorer rows; the signed `.app` passes `spctl -a`; benchmark rerun against a packaged reference build. |
-| Milestones | M20 parity | in progress | Nothing new; close the gaps the earlier milestones left (the gaps column of the unit rows). Completion check in port-m20-check, second run at d9dfa874f63: api-tests met (319/27/0 in the target's suites, #49125 run in a focused window, and 4/0/0; port/results/api-tests.md); pixel-check met after the Go Back color fix, the remaining differences are the causes in port/results/pixels.md; ledger not met: workbench/contrib/testing (M16) is the one `ported` row. Closed in workbench/contrib/comments: comment threads in diff and multi diff editors, floating ones included, with the floating style's `FloatingWidgetRoom`. | `port/tools/api-tests` gives 318/28/0 (folder) and 4/0/0 (workspace): the reference baseline 356/46/0 less the suites and tests of removed features (chat, lm, the integrated browser, `env.remoteName`) (port/results/api-tests-reference.md); pixel-check of every window has no difference beyond anti-aliasing and the causes listed in `port/results/pixels.md`; every ledger row is `verified`, `removed` or `n/a`. |
+| Milestones | M20 parity | in progress | Nothing new; close the gaps the earlier milestones left (the gaps column of the unit rows). Completion check in port-m20-check, second run at d9dfa874f63: api-tests met (319/27/0 in the target's suites, #49125 run in a focused window, and 4/0/0; port/results/api-tests.md); pixel-check met after the Go Back color fix, the remaining differences are the causes in port/results/pixels.md; ledger not met then: workbench/contrib/testing (M16) was the one `ported` row, `verified` since inline coverage. Closed in workbench/contrib/comments: comment threads in diff and multi diff editors, floating ones included, with the floating style's `FloatingWidgetRoom`. | `port/tools/api-tests` gives 318/28/0 (folder) and 4/0/0 (workspace): the reference baseline 356/46/0 less the suites and tests of removed features (chat, lm, the integrated browser, `env.remoteName`) (port/results/api-tests-reference.md); pixel-check of every window has no difference beyond anti-aliasing and the causes listed in `port/results/pixels.md`; every ledger row is `verified`, `removed` or `n/a`. |
| Milestones | M20 multi-instance code editor | done | Upstream every diff side, multi diff file side, notebook cell and walkthrough snippet is its own CodeEditorWidget. The port keeps one focused code editor per group bound to `text_area`, `editor_focus`, the input handler and `editors.active()`, as upstream's one focused widget takes the keys; every other code editor of the group keeps its own viewport, text area cells, minimap layout and find widget (code_editors.rs `parked`, `finds`) and draws through `text_area` as an inactive group's editor, with its own hover, color decorators, bracket guides and overview ruler; a press focuses it, a wheel scrolls it. Through it: the diff editor's original side (focus, selection, find), the multi diff file sides (the modified side takes typing and undo, its diff follows), notebook cells and playground snippets. | `cargo test -p app -- a_file_side_is_a_code_editor every_drawn_file_side the_original_side_takes_the_focus_selection_and_find each_group_keeps_its_own_find_widget the_focused_cell_is_the_code_editor unfocused_cell unfocused_snippet the_host_sees_the_code_editors_of_the_rendered_cells part_view::`: 17 passed; port/notes.md milestone 20, Multi-instance code editor |
| Milestones | M21 uplift to VS Code 1.148.0 | later | Postponed by Artur. Starts after milestones 11 to 20 close on 1.147.0 and after milestone 22; until then every reference, baseline and ui-pair stays on 1.147.0. Plan: `port/plans/uplift-1.147.0-to-1.148.0.md`, short form in `port/notes.md` "VS Code 1.148.0" (`bun port/tools/uplift-diff.ts 1.148.0`, every change triaged; refreshed against the ledger with 17 rows still open). Of about 209,000 changed upstream lines, 6,548 are ported: about 3,500 Rust work, 1,977 lines of grammar data and colorize fixtures, about 770 that arrive with upstream or the reference's extensions, and 308 of the floating comment style, a gap older than the uplift. 100,284 lines are skipped: AI, chat, sessions, agent host, remote, GitHub sign-in, experiments, telemetry and the integrated browser. Every setup step and work item is an `M21 uplift` row below, with its check. Steps: 1) session 1 does the setup rows and milestones 7 to 11. 2) Session 2 does milestones 12 and 14: files, workspace, the remove-folder vetoes and SCM. 3) Session 3 does milestones 13 and 15 to 19. Sessions 2 and 3 can run in parallel after session 1. | The ledger names 1.148.0. Every row the diff touches is `verified`, `removed` or `n/a` again, or keeps its 1.147.0 status where the gap is older than the uplift (the floating comment style). The full check passes against the 1.148.0 reference. |
| Milestones | M22 split the port from the VS Code tree | done | Artur: `main` holds the Rust port only (`native/`, `port/`, the port's skills, README and licenses) and upstream VS Code is `upstream/` (ignored), checked out detached at the followed tag, never edited; an uplift moves it with `git -C upstream checkout <tag>`. Every build step and tool reads upstream from `upstream/` or the path in `VSCODE_SRC`. Decision (Artur): `main` kept its history: a fast-forward by the port's branch plus one commit that removes the VS Code tree; no orphan commit, no `git filter-repo`, no force-push. Port version: the followed VS Code version is `package.json`'s `version` in `VSCODE_SRC`, which `uplift-diff.ts` reads as its default `from` and package-app as its default `VERSION`; `VERSION` in main.rs (the API version extensions see) repeats it. | Steps 1 and 2 (branch `port-m22-split`): `VSCODE_SRC` resolved by `native/vscode_src.rs` (build scripts of app, diff, files; `env!("VSCODE_SRC")`), `port/tools/vscode-src.sh` and `port/tools/vscode-src.ts`; the dev app root is `VSCODE_SRC` (runtime env over the build's value), the host bundle stays in the checkout's `out-exthost/`; the upstream edits are `port/patches/src-*.patch` (build-exthost, on a copy in `out-exthost/build`) and `extensions-*.patch` (package-app), `port/product.json` is the overlay. Step 3 (branch `port-release`): one commit `git rm`s the VS Code tree (21458 files); `ThirdPartyNotices.txt` ships from `VSCODE_SRC`, `LICENSE.txt` from the repo root; `exthost`'s `proposed_api.rs`, `run-app-check`'s extensions default and the dev host's AMD modules (`build-exthost` links `node_modules` beside `out-exthost` to `VSCODE_SRC`'s) read `VSCODE_SRC`; a Studio mirror of a tree without `src/` links `upstream` to `~/Developer/vscode-ref` (`port/tools/studio`). Step 4: a clean clone builds, tests, packages and passes the full check (the README's Build section at 96b0e476067). `git ls-tree main` holds no upstream file. |
@@ -640,7 +640,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 L] testing_coverage_view.rs: no inline coverage (codeCoverageDecorations.ts `CoverageToolbarWidget`, `testing.toggleInlineCoverage`, the line hover), no Filter Coverage to Test or Toggle Inline Coverage in the editor title (`testing.coverageFilterToTestInEditor`) | 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/testing | workbench contribution | M16 | verified | | 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; ui-pair m16/inline-coverage.json (Toggle Inline Coverage in the editor title, inline ranges with hit-count badges, the coverage toolbar) |
| 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 a3a80b63081..bf9da3edb03 100644
--- a/port/notes.md
+++ b/port/notes.md
@@ -892,6 +892,7 @@ Scope as in the M19 Work row of port/ledger.md.
- Debug visualizers (`workbench/debug_visualizers.rs`): a visualizer contributed with a Uri `iconPath` draws an empty button in the reference too: variablesView.ts builds the action with `class: v.iconClass || 'debug-viz-icon'`, reads no `iconPath`, and no stylesheet of 1.147.0 names `debug-viz-icon` (cargo test -p app debug_visualizers).
- View Binary Data (`workbench/debug_memory.rs`; variablesView.ts `VIEW_MEMORY_ID`, debugMemory.ts): the `vscode-debug-memory` provider lives in the workbench, and `exthost/src/main_thread_files.rs` asks it through `ask_workbench`. The answer waits on the workbench's own `readMemory` to js-debug, so `Session::ask_workbench` flushes the workbench's queued host calls while it waits; before that the hex editor's read hung on its LOADING placeholders. The provider has only `FileOpenReadWriteClose`, so upstream's file service reads with `read`, which ends the file at the first unreadable byte; the port's `readFile` returns that prefix. The range comes from an extension: it must be ordered, end at most at 2^53-1 and span at most 16 MiB. Inline row buttons show on hover or focus through `hidden()`/`flex()`: a `group_hover` display change skips prepaint and panics. ui-pair `debug/memory.json` needs `ms-vscode.hexeditor` 1.11.1 from Open VSX in `<dir>`, `ARGS="--extensions-dir <dir>"` and `FOLDER=port/fixtures/debug-node`. The hex editor's breadcrumbs are `3 > memory.bin` (breadcrumbsControl.ts takes a custom editor's resource of any scheme with a file system provider, `custom_editor_resource`): a resource of a scheme other than `file` and `vscode-userdata` has no workspace folder or `~` item, and its pickers list nothing, as debugMemory.ts `stat` makes every folder a file (cargo test -p app a_custom_editor_on_a_debug_memory_resource_has_breadcrumbs). shortcut: Space on its file item opens the resource as a text file without the session authority, which cannot be read; upgrade when breadcrumb elements keep the URI.
- Test coverage (`testing_coverage.rs`, `workbench/testing_coverage_view.rs`): `$appendCoverage` keeps each task's `TestCoverage` (testCoverage.ts) on `RunTask.coverage`, a prefix tree keyed by scheme, authority and path segments (lower-cased `file` paths on macOS, `extUri.ignorePathCasing`) whose folder nodes sum their files' counts, and the result's `hasCoverage` follows it. `$getCoverageDetails(resultId, taskIndex, uri)` answers from the extension host by the file's id, `[]` for an unknown file. testCoverageService.ts: a completed run opens its first task's coverage without focus, else closes it; `selected` is the result id and task id, gone with the result. The results tree's `CoverageElement` is a task's first child ("View Test Coverage" opens with focus on the Testing container, "Close Test Coverage" closes), with no twistie (`hideTwistiesOfChildlessElements`). The Test Coverage view (`workbench.view.testCoverage`, `when` `testing.isTestCoverageOpen`, after the Test Explorer; the Test Explorer's title gains Run Tests with Coverage, `CoverageSelectedAction`, once a coverage profile exists) lists from the root the first node that is a file or has several children, folders with one folder child on one row, sorted by location, name or coverage, each with the displayed percent and the statement, declaration and branch bars of testCoverageBars.ts; its title has Change Sort Order, Collapse All, Clear Coverage and, with per-test data, Filter Coverage by Test. The gutter (codeCoverageDecorations.ts `lineNumberClassName`) fills a line number covered, uncovered or striped from the file's statement and branch details, loaded once per file and test filter; `Transparent` colors clamp alpha at 1 as `RGBA` does (`testing.uncoveredGutterBackground` is the removed-text color at 1.5). The tests-provider fixture's Coverage profile reports each test line as a statement, covered when the test passed, with `loadDetailedCoverage` and `loadDetailedCoverageForTest`. ui-pair `port/fixtures/ui-pair/m16/coverage.json` on `port/fixtures/debug-node`.
+- Inline coverage (`testing_coverage.rs` `inline_coverage`, `workbench/coverage_decorations.rs`), codeCoverageDecorations.ts: `CoverageDetailsModel` ranges become backgrounds and borders over the text, primary ranges with a hit count get a `countBadge` (`99+x` past 99) as `InjectionOwner::Coverage` injected text, and a statement with an empty missed branch gets the missed-branch marker; they show with `testing.toggleInlineCoverage` (`testing.inlineCoverageEnabled`) or while the pointer is over the line numbers (`hoverLineNumber`), and a hovered range's line hover is `describe`'s markdown. The editor title shows Toggle Inline Coverage (`coverage`, toggled "Hide Inline Coverage") with `hasInlineCoverageDetails` and Filter Coverage to Test (`filter`, toggled `filter-filled`) with per-test data, both while `testing.coverageToolbarEnabled` is not true, its default. `CoverageToolbarWidget` is a 30px view zone over line 1 with an overlay drawn before the sticky scroll and the minimap (testing.css z-index 1 under their 4 and 5), in the UI font: the file's bars, Previous and Next Uncovered Line, Show or Hide Inline, the test filter label and Rerun (`debug-rerun`, disabled while its run is running). ui-pair `port/fixtures/ui-pair/m16/inline-coverage.json` on math.test.js.
- Checks: `cargo test -p app debug`, `cargo test -p app testing::` and `cargo test -p app coverage`; 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