Visual Studio Code, rebuilt in Rust
Rust
fix(statusbar): dashed HC hover outline and hover foreground on status icons
rokartur649c1510f369
diff --git a/native/crates/app/src/workbench.rs b/native/crates/app/src/workbench.rsindex 0523ee43da4..dc64a47727d 100644--- a/native/crates/app/src/workbench.rs+++ b/native/crates/app/src/workbench.rs@@ -2057,6 +2057,11 @@ impl Workbench {/// An icon rotated by `turns` of a full turn, clockwise.fn turned_icon(&self, name: &str, box_size: f32, icon_size: f32, color: Rgba, turns: f32) -> Div {+ self.styled_icon(name, box_size, icon_size, |icon| icon.text_color(color).with_transformation(gpui::Transformation::rotate(gpui::percentage(turns))))+ }++ /// An icon whose SVG `style` colors.+ fn styled_icon(&self, name: &str, box_size: f32, icon_size: f32, style: impl FnOnce(gpui::Svg) -> gpui::Svg) -> Div {let ids = crate::codicons::icon_ids(name);let icon = match self.product_icons.as_ref().and_then(|theme| theme.svg(&ids, icon_size)) {Some(glyph) => svg().data(glyph.as_bytes()),@@ -2073,7 +2078,7 @@ impl Workbench {.flex().items_center().justify_center()- .child(icon.size(px(icon_size)).text_color(color).with_transformation(gpui::Transformation::rotate(gpui::percentage(turns))))+ .child(style(icon.size(px(icon_size))))}}diff --git a/native/crates/app/src/workbench/diagnostics.rs b/native/crates/app/src/workbench/diagnostics.rsindex b818afc1f55..3bd3d48e62a 100644--- a/native/crates/app/src/workbench/diagnostics.rs+++ b/native/crates/app/src/workbench/diagnostics.rs@@ -250,7 +250,7 @@ impl Workbench {.on_click(cx.listener(|workbench, _, window, cx| drop(workbench.execute_command("workbench.actions.view.toggleProblems", Vec::new(), window, cx))));for (index, (icon, count)) in counts.iter().enumerate() {let separator = if index + 1 < counts.len() { " " } else { "" };- item = item.child(self.icon(icon, 16., 16., foreground)).child(format!(" {}{separator}", pack_number(*count)));+ item = item.child(self.status_item_icon(icon, 16., foreground)).child(format!(" {}{separator}", pack_number(*count)));}self.status_item_hover(item, None).child(self.hover_target("status.problems", HoverContent::Text(markers_tooltip(stats)), HoverOptions::status_bar()))}diff --git a/native/crates/app/src/workbench/hover/tests.rs b/native/crates/app/src/workbench/hover/tests.rsindex 3bc1eb7edbc..ab0920832ed 100644--- a/native/crates/app/src/workbench/hover/tests.rs+++ b/native/crates/app/src/workbench/hover/tests.rs@@ -219,6 +219,37 @@ fn the_status_bar_has_no_remote_indicator(cx: &mut TestAppContext) {assert_eq!(shown(&workbench, cx).as_deref(), Some("No Problems"));}+/// statusbarpart.css `.statusbar-item a:hover`: in high contrast the hovered label gets a 1px dashed+/// `contrastActiveBorder` outline, and its codicons (`color: inherit`) take `statusBarItem.hoverForeground`.+#[gpui::test]+fn a_hovered_status_item_is_outlined_and_its_icons_take_the_hover_foreground(cx: &mut TestAppContext) {+ let (workbench, cx) = open_workbench("hover-status-hc", cx);+ let (scale, border) = workbench.update_in(cx, |workbench, window, cx| {+ let themes = scan_extension(&workbench.app_root.join("extensions/theme-defaults"), true).unwrap();+ workbench.theme = load_theme(&[themes], "Default High Contrast").unwrap();+ workbench.theme.set_customizations(&serde_json::json!({ "statusBarItem.hoverForeground": "#FF0000" }), &serde_json::json!({}));+ cx.notify();+ (window.scale_factor(), workbench.theme.color("contrastActiveBorder").unwrap())+ });+ cx.run_until_parked();+ let problems = cx.debug_bounds("status-bar-entry-status.problems").expect("the problems entry is drawn");+ let inside = |bounds: Bounds<gpui::ScaledPixels>| problems.contains(&bounds.center().map(|v| px(v.0 / scale)));+ let painted = |cx: &mut gpui::VisualTestContext| {+ cx.read_rendered_frame(|scene, _| {+ let outlined = scene.quads.iter().any(|quad| inside(quad.bounds) && quad.border_style == gpui::BorderStyle::Dashed && quad.border_color == border.into() && quad.border_widths.top == gpui::ScaledPixels(scale));+ let icons: Vec<gpui::Hsla> = scene.monochrome_sprites.iter().filter(|sprite| inside(sprite.bounds) && sprite.bounds.size.width.0 >= 16. * scale).map(|sprite| sprite.color).collect();+ (outlined, icons)+ })+ };+ let (outlined, icons) = painted(cx);+ assert!(!outlined && !icons.is_empty() && !icons.contains(&gpui::rgb(0xFF0000).into()), "not hovered: {icons:?}");+ cx.simulate_mouse_move(problems.center(), None, Modifiers::none());+ cx.run_until_parked();+ let (outlined, icons) = painted(cx);+ assert!(outlined, "the hovered problems entry has the dashed outline");+ assert!(!icons.is_empty() && icons.iter().all(|color| *color == gpui::rgb(0xFF0000).into()), "{icons:?}");+}+#[gpui::test]fn a_hover_shows_after_the_delay_and_hides_when_the_pointer_leaves(cx: &mut TestAppContext) {let (workbench, cx) = open_workbench("hover", cx);diff --git a/native/crates/app/src/workbench/language_detection.rs b/native/crates/app/src/workbench/language_detection.rsindex 599df767d28..2b6ef2cc8ab 100644--- a/native/crates/app/src/workbench/language_detection.rs+++ b/native/crates/app/src/workbench/language_detection.rs@@ -238,7 +238,7 @@ impl Workbench {.items_center().px(px(3.)).cursor_pointer()- .child(self.icon("lightbulb-autofix", 16., 16., foreground))+ .child(self.status_item_icon("lightbulb-autofix", 16., foreground)).child(self.hover_target("language-detection-status", super::hover::HoverContent::Text(tooltip), super::hover::HoverOptions::status_bar())).on_click(cx.listener(|workbench, _, window, cx| drop(workbench.execute_command(DETECT_COMMAND, Vec::new(), window, cx))));Some(self.status_item_hover(item, None).into_any_element())diff --git a/native/crates/app/src/workbench/notifications_view.rs b/native/crates/app/src/workbench/notifications_view.rsindex c2cbee8eb65..9edbe12c646 100644--- a/native/crates/app/src/workbench/notifications_view.rs+++ b/native/crates/app/src/workbench/notifications_view.rs@@ -928,7 +928,7 @@ impl Workbench {// floatingPanels.css: the right edge label's padding is 4px in compact density.let size = if !left && self.compact_density() { 24. } else { 28. };let item = self- .icon(icon, size, 16., foreground)+ .status_item_icon(icon, size, foreground).id("status.notifications").h_full().cursor_pointer()diff --git a/native/crates/app/src/workbench/status_entries.rs b/native/crates/app/src/workbench/status_entries.rsindex 74ae3862a7e..22116977732 100644--- a/native/crates/app/src/workbench/status_entries.rs+++ b/native/crates/app/src/workbench/status_entries.rs@@ -25,6 +25,7 @@ const TOGGLE_ENTRY_PREFIX: &str = "workbench.statusBar.toggleEntry.";const HIDE_ENTRY_PREFIX: &str = "workbench.statusBar.hideEntry.";/// statusbarActions.ts `ManageExtensionAction`, one command per extension.const MANAGE_EXTENSION_PREFIX: &str = "statusbar.manage.extension.";+const STATUS_ITEM_GROUP: &str = "status-item";/// An entry the status bar drew or hid: statusbarModel.ts's `id`, `name` and `extensionId`.#[derive(Clone, Debug, PartialEq)]@@ -95,14 +96,25 @@ impl Workbench {}/// statusbarpart.css `.statusbar-item a:hover:not(.disabled)`: the label of an entry with a command takes its kind's- /// hover colors, in modernUI statusBar.css's cornerRadius.small (4px).+ /// hover colors, in modernUI statusBar.css's cornerRadius.small (4px), and in high contrast a 1px dashed+ /// `contrastActiveBorder` outline inside it.pub(super) fn status_item_hover(&self, item: Stateful<Div>, kind: Option<&str>) -> Stateful<Div> {let key = |part: &str| match kind {Some(kind) => format!("statusBarItem.{kind}Hover{part}"),None => format!("statusBarItem.hover{part}"),};let (background, foreground) = (self.color(&key("Background")), self.color(&key("Foreground")));- item.rounded(px(4.)).hover(move |item| item.bg(background).text_color(foreground))+ let outline = self.theme.color("contrastActiveBorder").map(|border| {+ div().absolute().inset_0().rounded(px(4.)).border_1().border_dashed().border_color(border).invisible().group_hover(STATUS_ITEM_GROUP, |outline| outline.visible())+ });+ item.group(STATUS_ITEM_GROUP).rounded(px(4.)).hover(move |item| item.bg(background).text_color(foreground)).children(outline)+ }++ /// statusbarpart.css `span.codicon { color: inherit }`: an icon of a `status_item_hover` label takes the hovered+ /// label's `statusBarItem.hoverForeground`.+ pub(super) fn status_item_icon(&self, name: &str, box_size: f32, foreground: Rgba) -> Div {+ let hover = self.color("statusBarItem.hoverForeground");+ self.styled_icon(name, box_size, 16., |icon| icon.text_color(foreground).group_hover(STATUS_ITEM_GROUP, move |icon| icon.text_color(hover)))}pub(super) fn status_bar_extension_entry(&self, entry: &StatusEntry, foreground: Rgba, cx: &mut Context<Self>) -> Option<AnyElement> {diff --git a/port/ledger.md b/port/ledger.mdindex 4517d59c9f3..bfea82f7b58 100644--- a/port/ledger.md+++ b/port/ledger.md@@ -360,7 +360,7 @@ One row per upstream unit, generated by `bun port/tools/gen-ledger.ts`; mileston| workbench/parts/partGrid | workbench part | M11 | verified | | workbench/layout.rs grid on split_view.rs (splitview.ts priorities, snap, visibility), workbench/part_grid.rs sashes, hidden parts, sizes and visibility in LayoutStateModel storage keys: cargo test -p app layout part_grid split_view (reference geometry at 1024x768, Cmd+B for the next open, sash drag, snap); ui-pair grid steps, port/results/layout.md || workbench/parts/sessions | workbench part | | removed | | no sign-in/AI by decision (port/notes.md); not ported || workbench/parts/sidebar | workbench part | M11 | verified | | Explorer and Search; compact activity bar for top and bottom (side_bar.rs) with every container the activity bar shows: built-in, Testing, extensions' `viewsContainers.activitybar` from startup and after an install, and generated ones (cargo test -p app the_top_activity_bar_shows_contributed_containers; it showed the five built-in ones only until then), No Folder Opened welcome in an empty window (empty_view.rs); pixel-check (port/results/pixels.md, milestone 3): chevron and label edge pixels only; ui-pair port/results/layout.md; verified: every pair of port/results/windows.md (milestone 11 verification) and port/results/references-view.md |-| workbench/parts/statusbar | workbench part | M11 | ported | [3 S] status_entries.rs status_item_hover: in High Contrast the hovered label lacks statusbarpart.css's 1px dashed `contrastActiveBorder` outline (outline-offset -1px); icons drawn in their own color (problems counts, bell, language detection) keep the item foreground on hover where the reference takes `statusBarItem.hoverForeground` | no-folder and folder colors (problems, bell), no remote indicator (workbench/contrib/remote removed, port/notes.md; cargo test -p app the_status_bar_has_no_remote_indicator), editor items Ln/Col, indentation, encoding, EOL, language with tabular-nums at their shaped widths and their upstream hovers; each item runs its editorStatus.ts command (Go to Line, indentation, encoding, EOL and language pickers: cargo test -p app editor_status); extension entries in statusbarModel.ts order around problems and the editor items (status_entries.rs), and the `status.progress` window progress entry with its spinner; verified: ui-pair messages.json vs the reference (port/results/windows.md, milestone 11 verification): extension entries, warning background, window progress entry, bell |+| workbench/parts/statusbar | workbench part | M11 | ported | [3 S] status_entries.rs extension_status_item: an entry's `$(icon)`s keep its color on hover where statusbarpart.css's `color: inherit` takes `statusBarItem.hoverForeground`, and an entry with its own `color` (statusbarItem.ts applyColor, an inline style on the label) still takes the hover foreground; HC dashed hover outline and problems, bell and language detection icons on hover not yet checked against the reference with ui-pair | no-folder and folder colors (problems, bell), no remote indicator (workbench/contrib/remote removed, port/notes.md; cargo test -p app the_status_bar_has_no_remote_indicator), a hovered label's HC dashed `contrastActiveBorder` outline and icons in `statusBarItem.hoverForeground` (a_hovered_status_item_is_outlined_and_its_icons_take_the_hover_foreground), editor items Ln/Col, indentation, encoding, EOL, language with tabular-nums at their shaped widths and their upstream hovers; each item runs its editorStatus.ts command (Go to Line, indentation, encoding, EOL and language pickers: cargo test -p app editor_status); extension entries in statusbarModel.ts order around problems and the editor items (status_entries.rs), and the `status.progress` window progress entry with its spinner; verified: ui-pair messages.json vs the reference (port/results/windows.md, milestone 11 verification): extension entries, warning background, window progress entry, bell || workbench/parts/titlebar | workbench part | M9 | verified | | command center with the folder name, nav and layout actions (Customize Layout runs since port/results/manage-menu.md; with the activity bar on top or bottom the title bar's Manage gear opens MenuId.GlobalActivity below it, cargo test -p app manage_menu); a click on the command center opens Quick Open with the Go to File and Show and Run Commands help picks (port/results/command-center.md); drag region as `-webkit-app-region` (empty bar drags and double-click zooms, command center and layout controls no-drag; cargo test -p app title_bar, port/results/command-center.md); context menus of the bar, the title and the command center with the Command Center, Navigation Controls and Layout Controls toggles and the path items (cargo test -p app title_bar); pixel-check file and titlebar (port/results/pixels.md): blending rounding and glyph edges only; the inactive window: `titleBar.inactiveBackground`/`inactiveForeground`, `commandCenter.inactiveBorder`, contents at 0.6 opacity, `modernUI.inactiveShellBackground` (cargo test -p app theme::tests; ui-pair `new-window.json`, port/results/windows.md) || workbench/parts/views | workbench part | M11 | verified | | Explorer views as panes (view_panes.rs): collapse by mouse and keys, sashes, header drag to reorder with drop overlay, state in workbench.explorer.views.state; no view actions, view menus or hidden views; cargo test -p app view_panes, ui-pair port/results/layout.md; pane headers drawn statically (workbench.rs section_header): no collapse, resize or view actions; verified: ui-pair port/results/references-view.md and every pair of port/results/windows.md (milestone 11 verification): the Explorer panes and contributed views as the reference; Explorer and Source Control views as panes of a ViewPaneContainer (view_panes.rs `PaneContainer`): collapse by mouse and keys, sashes, header drag to reorder with drop overlay, single view merged into the container, header actions, state in the container's storageId; cargo test -p app view_panes scm_container, ui-pair port/results/layout.md and port/fixtures/ui-pair/m11/scm-panes.json (port/notes.md View panes); verified: ui-pair port/results/references-view.md and every pair of port/results/windows.md (milestone 11 verification): the Explorer panes and contributed views as the reference; Run and Debug, Extensions and webview containers still draw section_header rows: no collapse, resize or view actions; welcome buttons draw their `$(icon)`s (cargo test -p app a_welcome_button_draws_its_label_icons; ui-pair port/fixtures/ui-pair/icons/scm-welcome.json: github's Publish to GitHub button with the github codicon as the reference); wrapped text stacks unsnapped 18.2px lines as Chromium (vendor gpui elements/text.rs; cargo test -p app wrapped_lines_keep_their_fractional_line_height): scm-welcome's Publish button 0.5pt from the reference, was 2.5pt; left: the port wraps "Git" of "To learn more about how to use Git" to the next line; a merged view's "..." puts the Views submenu, a separator and the view's own actions (panecomposite.ts `getSecondaryActions`; cargo test -p app a_merged_changes_view_shows_the_views_submenu_in_its_more_actions a_merged_view_without_actions_lists_the_view_toggles_flat) || workbench/services/accessibility | workbench service | M19 | verified | | electron-browser accessibilityService.ts over GPUI: screen reader attach follows Electron's `isAccessibilitySupportEnabled` on macOS (VoiceOver, or an assistive app setting AXManualAccessibility or AXEnhancedUserInterface, as cua-driver does; ui-pair screen-reader-detection.json with accessibility support auto shows the prompt in both), the Screen reader usage detected prompt and status entry; port/tools/a11y-check; cargo test -p app accessib; electron-browser accessibilityService.ts over GPUI: screen reader attach follows is_a11y_active, the Screen reader usage detected prompt and status entry; port/tools/a11y-check; cargo test -p app accessib |