( env: CliEnv = getCliEnv(), )
| 574 | } |
| 575 | |
| 576 | const detectZedTheme = ( |
| 577 | env: CliEnv = getCliEnv(), |
| 578 | ): ThemeName | null => { |
| 579 | if (!isZedTerminal(env)) { |
| 580 | return null |
| 581 | } |
| 582 | |
| 583 | const settingsPaths = collectExistingPaths(resolveZedSettingsPaths(env)) |
| 584 | for (const settingsPath of settingsPaths) { |
| 585 | const content = safeReadFile(settingsPath) |
| 586 | if (!content) continue |
| 587 | |
| 588 | const theme = extractZedTheme(content) |
| 589 | if (theme) { |
| 590 | return theme |
| 591 | } |
| 592 | |
| 593 | // If extractZedTheme returned null, check if theme mode is 'system' |
| 594 | // and fall back to platform detection |
| 595 | try { |
| 596 | const sanitized = stripJsonStyleComments(content) |
| 597 | const parsed = JSON.parse(sanitized) as Record<string, unknown> |
| 598 | const themeSetting = parsed.theme |
| 599 | if (themeSetting && typeof themeSetting === 'object') { |
| 600 | const themeConfig = themeSetting as Record<string, unknown> |
| 601 | const modeRaw = themeConfig.mode |
| 602 | if (typeof modeRaw === 'string' && modeRaw.toLowerCase() === 'system') { |
| 603 | return detectPlatformTheme() |
| 604 | } |
| 605 | } |
| 606 | } catch { |
| 607 | // Ignore parsing errors |
| 608 | } |
| 609 | } |
| 610 | |
| 611 | return null |
| 612 | } |
| 613 | |
| 614 | export const detectIDETheme = ( |
| 615 | env: CliEnv = getCliEnv(), |
no test coverage detected