Visual Studio Code, rebuilt in Rust
Rust
feat(testing): mark covered and missed lines in the minimap gutter
rokartur51dd44adcd4c
diff --git a/native/crates/app/src/theme/debug_colors.rs b/native/crates/app/src/theme/debug_colors.rsindex 33384586175..b0ff373a89e 100644--- a/native/crates/app/src/theme/debug_colors.rs+++ b/native/crates/app/src/theme/debug_colors.rs@@ -43,12 +43,12 @@ pub(super) fn debug_default(key: &str) -> Option<[ColorValue; 4]> {}"statusBar.debuggingForeground" => [Key("statusBar.foreground"), Key("statusBar.foreground"), Key("statusBar.foreground"), Hex("#FFFFFF")],"testing.iconFailed" | "testing.iconErrored" => [Key("list.errorForeground"), Key("list.errorForeground"), Key("list.errorForeground"), Key("list.errorForeground")],- // testing/browser/theme.ts: the gutter of codeCoverageDecorations.ts.- "testing.coveredGutterBackground" => {+ // testing/browser/theme.ts: the gutter and minimap of codeCoverageDecorations.ts.+ "testing.coveredGutterBackground" | "testing.coveredMinimapBackground" => {const COVERED: ColorValue = Transparent(&Key("diffEditor.insertedTextBackground"), 0.6);[COVERED, COVERED, Key("charts.green"), Key("charts.green")]}- "testing.uncoveredGutterBackground" => {+ "testing.uncoveredGutterBackground" | "testing.uncoveredMinimapBackground" => {const UNCOVERED: ColorValue = Transparent(&Key("diffEditor.removedTextBackground"), 1.5);[UNCOVERED, UNCOVERED, Key("charts.red"), Key("charts.red")]}diff --git a/native/crates/app/src/workbench/minimap_view.rs b/native/crates/app/src/workbench/minimap_view.rsindex 943343ef3b0..cb28fa71102 100644--- a/native/crates/app/src/workbench/minimap_view.rs+++ b/native/crates/app/src/workbench/minimap_view.rs@@ -298,7 +298,7 @@ impl Workbench {let sampling = info.is_sampling.then(|| Rc::new(self.sticky_minimap_sampling(editor, viewport, pixel_ratio, settings.layout)));let layout = self.minimap_layout(editor, info, pixel_ratio, viewport, sampling.as_deref());let image = self.minimap_image(editor, &info, &layout, sampling.as_deref());- let fills = self.minimap_decorations(editor, &info, &layout, sampling.as_deref());+ let fills = self.minimap_decorations(editor, &info, &layout, sampling.as_deref(), cx);let label_options = self.section_header_options();let labels = self.minimap_section_labels(editor, &info, pixel_ratio, &layout, &label_options, sampling.as_deref());let background = self.minimap_background();@@ -480,7 +480,7 @@ impl Workbench {/// `renderDecorations`: the selections in `minimap.selectionHighlight`, then the word highlights in/// `minimap.selectionOccurrenceHighlight`, the collapsed folds' whole lines in `editor.foldBackground` and the find/// matches in `minimap.findMatchHighlight`.- fn minimap_decorations(&self, editor: &OpenEditor, info: &MinimapLayoutInfo, layout: &MinimapLayout, sampling: Option<&MinimapSampling>) -> Vec<crate::editor::minimap::Fill> {+ fn minimap_decorations(&self, editor: &OpenEditor, info: &MinimapLayoutInfo, layout: &MinimapLayout, sampling: Option<&MinimapSampling>, cx: &mut Context<Self>) -> Vec<crate::editor::minimap::Fill> {// convertModelPositionToViewPosition: a hidden position shows at the end of its fold line.let view = |line: usize, column: usize| {if editor.folding.is_hidden(line) {@@ -536,8 +536,12 @@ impl Workbench {}let tab_size = editor.document().indentation.tab_size;let mut fills = decoration_fills(info, layout, self.theme.color("minimap.selectionHighlight"), &selections, &decorations, tab_size, |minimap_line| editor.view_line_text(sampled_view_line(sampling, minimap_line) - 1));- // minimap.ts `_renderDecorationsHighlights` for `MinimapPosition.Gutter` (the quick diff's): 2px at x 2.- for (start, end, color) in self.quick_diff_minimap_lines(editor) {+ // minimap.ts `_renderDecorationsHighlights` for `MinimapPosition.Gutter` (the quick diff's and coverage's): 2px+ // at x 2, in start line order.+ let mut gutter_lines = self.quick_diff_minimap_lines(editor);+ gutter_lines.extend(self.coverage_minimap_lines(&editor.document().uri(), editor.document().lines.len(), cx));+ gutter_lines.sort_by_key(|(start, ..)| *start);+ for (start, end, color) in gutter_lines {let (mut first, mut last) = (view(start, 0).0, view(end, 0).0);if let Some(sampling) = sampling {(first, last) = sampling.decoration_lines(first, last);diff --git a/native/crates/app/src/workbench/testing_coverage_view.rs b/native/crates/app/src/workbench/testing_coverage_view.rsindex 38d5958f2d5..3ea9e76a956 100644--- a/native/crates/app/src/workbench/testing_coverage_view.rs+++ b/native/crates/app/src/workbench/testing_coverage_view.rs@@ -493,6 +493,18 @@ impl Workbench {lines}+ /// codeCoverageDecorations.ts `apply` with `testing.coverageMinimapEnabled`: each covered or missed line in the+ /// minimap's gutter, as `(first line, last line, color)`. A line both hit and missed shows the miss.+ pub(super) fn coverage_minimap_lines(&self, uri: &Value, line_count: usize, cx: &mut Context<Self>) -> Vec<(usize, usize, Rgba)> {+ if self.setting("testing.coverageMinimapEnabled") == json!(false) {+ return Vec::new();+ }+ let (hit, miss) = (self.color("testing.coveredMinimapBackground"), self.color("testing.uncoveredMinimapBackground"));+ let mut lines: Vec<_> = self.coverage_lines(uri, line_count, cx).into_iter().map(|(line, marks)| (line, line, if marks.miss { miss } else { hit })).collect();+ lines.sort_by_key(|(line, ..)| *line);+ lines+ }+/// 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]> {let (_, _, coverage) = self.selected_coverage()?;diff --git a/native/crates/app/src/workbench/testing_coverage_view/tests.rs b/native/crates/app/src/workbench/testing_coverage_view/tests.rsindex e2bb320b029..47a6577a897 100644--- a/native/crates/app/src/workbench/testing_coverage_view/tests.rs+++ b/native/crates/app/src/workbench/testing_coverage_view/tests.rs@@ -178,6 +178,34 @@ fn the_gutter_marks_covered_and_missed_lines(cx: &mut TestAppContext) {assert_eq!(lines, vec![(0, true, false), (2, false, true)]);}+/// codeCoverageDecorations.ts `apply`: with `testing.coverageMinimapEnabled` each covered or missed line also marks the+/// minimap's gutter, a line both hit and missed in the miss color.+#[gpui::test]+fn the_minimap_marks_covered_and_missed_lines_until_the_setting_turns_off(cx: &mut TestAppContext) {+ let (workbench, cx, _host) = workbench_with_tests("coverage-minimap", TESTS, cx);+ let user = std::env::temp_dir().join(format!("vsrustium-coverage-minimap-user-{}", std::process::id()));+ let (lines, off, colors) = 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)));+ 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": 3 } });+ 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": 1, "location": range(1) }), json!({ "type": 1, "count": 1, "location": range(3) }), 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));+ let lines = workbench.coverage_minimap_lines(&uri, 3, cx);+ workbench.settings.lock().unwrap().update_value_derived("testing.coverageMinimapEnabled", Some(&json!(false))).unwrap();+ let off = workbench.coverage_minimap_lines(&uri, 3, cx);+ (lines, off, (workbench.color("testing.coveredMinimapBackground"), workbench.color("testing.uncoveredMinimapBackground")))+ });+ std::fs::remove_dir_all(user).unwrap();+ assert_eq!(lines, vec![(0, 0, colors.0), (2, 2, colors.1)]);+ assert!(off.is_empty(), "the setting turns the marks off");+}+/// 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/port/ledger.md b/port/ledger.mdindex c38c9d53028..c169af8f028 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 minimap or overview ruler marks (`testing.coverageMinimapEnabled`) | 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`) | 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) |