( env: CliEnv = getCliEnv(), )
| 431 | } |
| 432 | |
| 433 | const detectVSCodeTheme = ( |
| 434 | env: CliEnv = getCliEnv(), |
| 435 | ): ThemeName | null => { |
| 436 | if (!isVSCodeFamilyTerminal(env)) { |
| 437 | return null |
| 438 | } |
| 439 | |
| 440 | const settingsPaths = collectExistingPaths(resolveVSCodeSettingsPaths(env)) |
| 441 | |
| 442 | for (const settingsPath of settingsPaths) { |
| 443 | const content = safeReadFile(settingsPath) |
| 444 | if (!content) continue |
| 445 | const theme = extractVSCodeTheme(content) |
| 446 | if (theme) { |
| 447 | return theme |
| 448 | } |
| 449 | |
| 450 | // If extractVSCodeTheme returned null but auto-detect is enabled, |
| 451 | // use platform theme as fallback |
| 452 | const autoDetectMatch = content.match( |
| 453 | /"window\.autoDetectColorScheme"\s*:\s*(true|false)/i, |
| 454 | ) |
| 455 | if (autoDetectMatch?.[1]?.toLowerCase() === 'true') { |
| 456 | return detectPlatformTheme() |
| 457 | } |
| 458 | } |
| 459 | |
| 460 | const themeKindEnv = |
| 461 | env.VSCODE_THEME_KIND ?? env.VSCODE_COLOR_THEME_KIND |
| 462 | if (themeKindEnv) { |
| 463 | const normalized = themeKindEnv.trim().toLowerCase() |
| 464 | if (normalized === 'dark' || normalized === 'hc') return 'dark' |
| 465 | if (normalized === 'light') return 'light' |
| 466 | } |
| 467 | |
| 468 | return null |
| 469 | } |
| 470 | |
| 471 | const detectJetBrainsTheme = ( |
| 472 | env: CliEnv = getCliEnv(), |
no test coverage detected