| ... | @@ -1,8 +1,10 @@ | ... | @@ -1,8 +1,10 @@ |
| 1 | import { | 1 | import { |
| 2 | createVividThemeColors, | 2 | createVividThemeColors, |
| 3 | getThemeModes, | 3 | getThemeModes, |
| | 4 | isReservedThemeId, |
| 4 | parseThemeFile, | 5 | parseThemeFile, |
| 5 | themeColorToHex, | 6 | themeColorToHex, |
| | 7 | themeIdFromName, |
| 6 | THEME_FILE_VERSION, | 8 | THEME_FILE_VERSION, |
| 7 | type ThemeAppearance, | 9 | type ThemeAppearance, |
| 8 | type ThemeColorRole, | 10 | type ThemeColorRole, |
| ... | @@ -321,9 +323,12 @@ export function parseVsCodeThemeFile(value: unknown): ThemeDefinition { | ... | @@ -321,9 +323,12 @@ export function parseVsCodeThemeFile(value: unknown): ThemeDefinition { |
| 321 | | 323 | |
| 322 | // Reuse the theme-file parser so ids, names, and color values go through the | 324 | // Reuse the theme-file parser so ids, names, and color values go through the |
| 323 | // same validation as a hand-written file. | 325 | // same validation as a hand-written file. |
| | 326 | const name = resolveName(value); |
| | 327 | const generatedId = themeIdFromName(name); |
| 324 | return parseThemeFile({ | 328 | return parseThemeFile({ |
| 325 | version: THEME_FILE_VERSION, | 329 | version: THEME_FILE_VERSION, |
| 326 | name: resolveName(value), | 330 | ...(isReservedThemeId(generatedId) ? { id: `${generatedId}-vscode` } : {}), |
| | 331 | name, |
| 327 | appearance, | 332 | appearance, |
| 328 | colors: { ...derived, ...overrides }, | 333 | colors: { ...derived, ...overrides }, |
| 329 | }); | 334 | }); |
| ... | @@ -352,9 +357,11 @@ export function pairVsCodeThemes( | ... | @@ -352,9 +357,11 @@ export function pairVsCodeThemes( |
| 352 | const passthrough: Array<{ theme: ThemeDefinition; order: number }> = []; | 357 | const passthrough: Array<{ theme: ThemeDefinition; order: number }> = []; |
| 353 | themes.forEach((theme, order) => { | 358 | themes.forEach((theme, order) => { |
| 354 | // Only single-appearance themes with an appearance word in the name can | 359 | // Only single-appearance themes with an appearance word in the name can |
| 355 | // 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. |
| 356 | const key = stripAppearance(theme.label); | 363 | const key = stripAppearance(theme.label); |
| 357 | 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)) { |
| 358 | passthrough.push({ theme, order }); | 365 | passthrough.push({ theme, order }); |
| 359 | return; | 366 | return; |
| 360 | } | 367 | } |