Skip to content

Commit f035003

Browse files
committed
fix(web): keep Dark+ and Light+ unpaired instead of merging them as +
1 parent ea00d60 commit f035003

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

‎apps/web/src/vscodeThemeImport.test.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,25 @@ describe("VS Code theme import", () => {
123123
expect(darkPlus.id).toBe("dark-vscode");
124124
});
125125

126+
it("keeps Dark+ and Light+ as separate themes instead of pairing them as +", () => {
127+
const themes = pairVsCodeThemes([
128+
parseVsCodeThemeFile({
129+
name: "Light+",
130+
type: "light",
131+
colors: { "editor.background": "#ffffff" },
132+
}),
133+
parseVsCodeThemeFile({
134+
name: "Dark+",
135+
type: "dark",
136+
colors: { "editor.background": "#1e1e1e" },
137+
}),
138+
]);
139+
expect(themes.map((theme) => [theme.id, theme.label])).toEqual([
140+
["light-vscode", "Light+"],
141+
["dark-vscode", "Dark+"],
142+
]);
143+
});
144+
126145
it("fills every role the file omits with a readable derived value", () => {
127146
const theme = parseVsCodeThemeFile(VSCODE_DARK);
128147
const colors = getThemeColorsForMode(theme, "dark")!;

‎apps/web/src/vscodeThemeImport.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,11 @@ export function pairVsCodeThemes(
357357
const passthrough: Array<{ theme: ThemeDefinition; order: number }> = [];
358358
themes.forEach((theme, order) => {
359359
// Only single-appearance themes with an appearance word in the name can
360-
// pair; anything else is already what the user asked for.
360+
// pair, and only when the rest of the name can still identify the pair
361+
// ("Dark+" and "Light+" would pair as "+"); anything else is already
362+
// what the user asked for.
361363
const key = stripAppearance(theme.label);
362-
if (getThemeModes(theme).length !== 1 || key === theme.label || key.length === 0) {
364+
if (getThemeModes(theme).length !== 1 || key === theme.label || !/[a-z0-9]/i.test(key)) {
363365
passthrough.push({ theme, order });
364366
return;
365367
}

0 commit comments

Comments
 (0)