Visual Studio Code, rebuilt in Rust
Rust
test(theme): check the 1.148.0 Light Modern and Light 2026 defaults
rokarturd50bd2ec902b
diff --git a/native/crates/app/src/theme.rs b/native/crates/app/src/theme.rsindex 85c608619cb..9d576653f23 100644--- a/native/crates/app/src/theme.rs+++ b/native/crates/app/src/theme.rs@@ -424,6 +424,12 @@ pub fn relative_luminance(color: Rgba) -> f64 {(luminance * 10_000.).round() / 10_000.}+/// `Color.getContrastRatio`.+pub fn contrast_ratio(a: Rgba, b: Rgba) -> f64 {+ let (a, b) = (relative_luminance(a), relative_luminance(b));+ (a.max(b) + 0.05) / (a.min(b) + 0.05)+}+/// colorUtils.ts `lessProminent`: `Color.getLighterColor` or `getDarkerColor` relative to the background, then/// `transparent`, through `Color`'s HSLA with its rounding (hue to an integer, the rest to 3 decimals).fn less_prominent(color: Rgba, background: Rgba, factor: f32, transparency: f32) -> Rgba {@@ -1830,4 +1836,39 @@ mod tests {assert_eq!(loaded, 19);assert_eq!(builtin_theme("Default High Contrast Light").kind, ThemeKind::HighContrastLight);}++ /// defaultThemeColors.test.ts "Light Modern Quick Pick focus is distinct from idle and hovered rows with readable content".+ #[test]+ fn light_modern_quick_pick_focus_is_distinct_from_idle_and_hovered_rows_with_readable_content() {+ let theme = builtin_theme("Light Modern");+ let background = theme.color("quickInput.background").unwrap();+ let focused = make_opaque(theme.color("quickInputList.focusBackground").unwrap(), background);+ let hovered = make_opaque(theme.color("list.hoverBackground").unwrap(), background);+ assert!(contrast_ratio(focused, background) >= 3.);+ assert!(contrast_ratio(focused, hovered) >= 3.);+ for id in ["quickInputList.focusForeground", "quickInputList.focusIconForeground", "quickInputList.focusHighlightForeground"] {+ assert!(contrast_ratio(make_opaque(theme.color(id).unwrap(), focused), focused) >= 4.5, "{id}");+ }+ }++ /// defaultThemeColors.test.ts "Light 2026 connected tabs have a light strip, visible dividers, and readable labels".+ #[test]+ fn light_2026_connected_tabs_have_a_light_strip_visible_dividers_and_readable_labels() {+ let mut theme = builtin_theme("Light 2026");+ let strip = make_opaque(theme.color("editorGroupHeader.connectedTabsBackground").unwrap(), theme.color("editor.background").unwrap());+ let divider = make_opaque(theme.color("tab.divider").unwrap(), strip);+ assert!(relative_luminance(strip) >= 0.85);+ assert!(relative_luminance(divider) < relative_luminance(strip));+ assert!(contrast_ratio(divider, strip) >= 1.3);+ for id in ["editor.background", "sideBar.background", "panel.background"] {+ assert!(contrast_ratio(theme.color(id).unwrap(), strip) >= 1.08, "{id}");+ }+ for id in ["tab.inactiveForeground", "activityBarTop.inactiveForeground", "panelTitle.inactiveForeground"] {+ assert!(contrast_ratio(make_opaque(theme.color(id).unwrap(), strip), strip) >= 4.5, "{id}");+ }++ theme.set_customizations(&json!({ "editorGroupHeader.connectedTabsBackground": "#123456", "tab.divider": "#abcdef" }), &json!({}));+ assert_eq!(theme.color("editorGroupHeader.connectedTabsBackground").map(hex).as_deref(), Some("#123456ff"));+ assert_eq!(theme.color("tab.divider").map(hex).as_deref(), Some("#abcdefff"));+ }}diff --git a/native/crates/app/src/workbench/inspect_tokens.rs b/native/crates/app/src/workbench/inspect_tokens.rsindex 95e3e424281..2a377d9df8b 100644--- a/native/crates/app/src/workbench/inspect_tokens.rs+++ b/native/crates/app/src/workbench/inspect_tokens.rs@@ -18,7 +18,7 @@ use super::editor_message::horizontal_in_page;use crate::commands::Outcome;use crate::editor::{OpenEditor, Position, TextDocument, char_column, utf16_column};use crate::semantic_tokens::{RuleScope, SemanticTheme, SemanticTokensLegend, TokenStyle, TokenStyleDefinition};-use crate::theme::{Theme, parse_hex, relative_luminance};+use crate::theme::{Theme, contrast_ratio, parse_hex};const UI_FONT: &str = ".SystemUIFont";const MONOSPACE_FONT: &str = "Menlo";@@ -569,12 +569,6 @@ fn make_opaque(color: gpui::Rgba, background: gpui::Rgba) -> gpui::Rgba {gpui::Rgba { r: blend(color.r, background.r), g: blend(color.g, background.g), b: blend(color.b, background.b), a: 1. }}-/// `Color.getContrastRatio`.-fn contrast_ratio(a: gpui::Rgba, b: gpui::Rgba) -> f64 {- let (a, b) = (relative_luminance(a), relative_luminance(b));- (a.max(b) + 0.05) / (a.min(b) + 0.05)-}-/// TMHelper.ts `findMatchingThemeRule` with `onlyColorRules` false: from the innermost scope out, the most specific/// selector matching the scope under its parents, a later rule winning a tie; its raw selector and settings JSON.fn find_matching_theme_rule(rules: &[Value], scopes: &[&str]) -> Option<(String, String)> {diff --git a/port/ledger.md b/port/ledger.mdindex 61ed7beaf8f..cfa0df2db3f 100644--- a/port/ledger.md+++ b/port/ledger.md@@ -110,7 +110,7 @@ Status: `open`, `in progress`, `waiting on Artur`, `later` (postponed), `done`,| M21 uplift | setup: version bump | done | 1.148.0 in `VERSION` (`native/crates/app/src/main.rs`), in this file's header and 1:1 rule, and in README.md's coverage line (`port/tools/readme-coverage.ts` now reads the version from upstream's `package.json`); evidence that names a 1.147.0 dump keeps its version. `bun port/tools/gen-ledger.ts` added one unit: `mainthread/MainThreadRemoteAgentHosts`, `removed` (remote agent hosts). `mainthread/MainThreadGitExtensionService` (21 lines) is a client of the removed IGitService and stays with the `removed` row `mainthread/MainThreadGitExtension`. | `bun port/tools/ledger-check.ts` exits 0; 595 rows (2026-12-01) || M21 uplift | setup: diff recount | done | Run `bun port/tools/uplift-diff.ts 1.148.0 1.147.0` on the split tree and compare its group counts with section 1 of `port/plans/uplift-1.147.0-to-1.148.0.md`. Same as the plan but for the new `removed` row `mainthread/MainThreadRemoteAgentHosts` (36 lines), which moves from "new upstream unit" to "removed by decision". | to port 79 rows (10,606 lines), new unit 1 (21, `mainthread/MainThreadGitExtensionService`), removed by decision 32 (78,874), tests only 8, API typings 5, not mapped 29 folders (2026-12-01) || M21 uplift | extension/* grammars | done | M7. New upstream grammar commits for cpp, csharp, dart, dotenv, go, java, latex, log, php, razor, rust and scss (1,265 lines of data) arrive with the reference's extensions; the colorize fixtures `test-80644_cpp`, `test_env` and `test_tex` change (712 lines). No port code: the test reads grammars, fixtures and results from the 1.148.0 tree. | `cargo test -p app syntax` on the 1.148.0 tree: 17 passed, `colorize_fixtures_match_the_reference` ok (2026-12-01) |-| M21 uplift | extension/theme-defaults | later | M7, 8 lines. Light 2026: `editorGroupHeader.connectedTabsBackground` #EAEAEA to #F0F0F3, `tab.divider` #CECECE, `activityBarTop.inactiveForeground` #606060. Light Modern: the quick pick's focused row is #005FB8 with #FFFFFF foreground, icon and highlight. | ui-pair 2026-light tab bar and top activity bar, light_modern Cmd+P; the defaultThemeColors.test.ts cases (74 lines) in `cargo test -p app theme` |+| M21 uplift | extension/theme-defaults | done | M7, 8 lines. Light 2026: `editorGroupHeader.connectedTabsBackground` #EAEAEA to #F0F0F3, `tab.divider` #CECECE, `activityBarTop.inactiveForeground` #606060. Light Modern: the quick pick's focused row is #005FB8 with #FFFFFF foreground, icon and highlight. | The themes are read from the 1.148.0 extension, no code: `cargo test -p app -- theme::` on the 1.148.0 tree, `light_modern_quick_pick_focus_is_distinct_from_idle_and_hovered_rows_with_readable_content` and `light_2026_connected_tabs_have_a_light_strip_visible_dividers_and_readable_labels` pass (both fail on 1.147.0's themes), `resolved_colors_match_the_reference_workbench_variables` against the 1.148.0 `ref-dom` dump; ui-pair not run (2026-12-01) || M21 uplift | workbench/services/themes | later | M7, 26 lines (`modernTabColorCustomizations.ts`, `tabDividerColor.ts`): modern tabs fall back to `editorGroupHeader.tabsBorder` for the tab border, and `tab.divider` follows a customized `tab.border` unless `tab.divider` is customized itself. | `cargo test -p app theme` with the 3 cases of the new test || M21 uplift | editor/contrib/suggest | later | M13, 6 lines (`suggestWidget.ts`): the default of `editorSuggestWidget.focusHighlightForeground` becomes `quickInputList.focusHighlightForeground`; when the theme sets `editorSuggestWidget.selectedBackground` it is `list.focusHighlightForeground` (`ifDefinedThenElse`). | `cargo test -p app theme` color defaults || M21 uplift | editor/browser and editor/contrib/folding | later | M8, 71 lines (`mouseHandler`, `mouseTarget`, `view`, `viewLine`, `folding.css`): a click in the empty gutter places the caret; a click in the line-decorations lane with no decoration goes to the line start; only the 0.625em folding chevron toggles; with `editor.mouseStyle: text` the I-beam shows over the empty gutter; a click right of an empty line gives column 1; an empty line with injected text on both sides puts the caret before the after-decoration. | `cargo test -p app editor::view` mouse-target cases; ui-pair of the gutter hover |