Skip to content

Visual Studio Code, rebuilt in Rust

Rust

feat(testing): outline the coverage gutter in high contrast

rokartur98dae7f6a8ee
diff --git a/native/crates/app/src/workbench/testing_coverage_view.rs b/native/crates/app/src/workbench/testing_coverage_view.rs
index 124db15aef3..cfca2c02867 100644
--- a/native/crates/app/src/workbench/testing_coverage_view.rs
+++ b/native/crates/app/src/workbench/testing_coverage_view.rs
@@ -436,13 +436,21 @@ impl Workbench {
/// The `coverage-deco-gutter` background of a line number: covered, uncovered, or both striped (testing.css).
pub(super) fn coverage_gutter(&self, line: LineCoverage) -> Option<Div> {
let (hit, miss) = (self.color("testing.coveredGutterBackground"), self.color("testing.uncoveredGutterBackground"));
+ let high_contrast = self.theme.kind.is_high_contrast();
let fill = div().absolute().inset_0();
- match (line.hit, line.miss) {
- (true, true) => Some(fill.child(super::editor_view::quick_diff::stripes(hit, miss, 6., true))),
- (true, false) => Some(fill.bg(hit)),
- (false, true) => Some(fill.bg(miss)),
- (false, false) => None,
- }
+ let fill = match (line.hit, line.miss) {
+ (false, false) => return None,
+ (true, true) => fill.child(super::editor_view::quick_diff::stripes(hit, miss, 6., true)),
+ _ if high_contrast => fill,
+ (true, false) => fill.bg(hit),
+ (false, true) => fill.bg(miss),
+ };
+ // testing.css `.hc-black .coverage-deco-gutter::before`: borders and no fill, though the striped rule outranks
+ // it; a line both hit and missed takes the miss rule's border color, declared last.
+ Some(match high_contrast {
+ true => fill.border_t(px(3.)).border_b(px(3.)).border_l(px(5.)).border_color(if line.miss { miss } else { hit }),
+ false => fill,
+ })
}
}
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 5f3639239d0..a4fc9446037 100644
--- a/native/crates/app/src/workbench/testing_coverage_view/tests.rs
+++ b/native/crates/app/src/workbench/testing_coverage_view/tests.rs
@@ -177,3 +177,21 @@ fn the_gutter_marks_covered_and_missed_lines(cx: &mut TestAppContext) {
});
assert_eq!(lines, vec![(0, true, false), (2, false, true)]);
}
+
+/// 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]
+fn the_high_contrast_gutter_draws_borders_instead_of_fills(cx: &mut TestAppContext) {
+ use gpui::Styled;
+ let (workbench, cx, _host) = workbench_with_tests("coverage-gutter-hc", TESTS, cx);
+ workbench.update_in(cx, |workbench, _, _| {
+ let themes = exthost::scan::scan_extension(&workbench.app_root.join("extensions/theme-defaults"), true).unwrap();
+ workbench.theme = crate::theme::load_theme(&[themes], "Default High Contrast").unwrap();
+ let mut hit = workbench.coverage_gutter(crate::workbench::testing_coverage_view::LineCoverage { hit: true, miss: false }).expect("a covered line");
+ let style = hit.style();
+ let widths = &style.border_widths;
+ assert_eq!((widths.top, widths.bottom, widths.left, widths.right), (Some(gpui::px(3.).into()), Some(gpui::px(3.).into()), Some(gpui::px(5.).into()), None));
+ assert_eq!(style.border_color, Some(workbench.color("testing.coveredGutterBackground").into()));
+ assert!(style.background.is_none(), "no fill");
+ });
+}
diff --git a/port/ledger.md b/port/ledger.md
index 6b94d2d462d..0c4ad025311 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 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/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`) | 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) |