MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / detectVSCodeTheme

Function detectVSCodeTheme

cli/src/utils/theme-system.ts:433–469  ·  view source on GitHub ↗
(
  env: CliEnv = getCliEnv(),
)

Source from the content-addressed store, hash-verified

431}
432
433const 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
471const detectJetBrainsTheme = (
472 env: CliEnv = getCliEnv(),

Callers 1

detectIDEThemeFunction · 0.85

Calls 7

getCliEnvFunction · 0.90
isVSCodeFamilyTerminalFunction · 0.85
collectExistingPathsFunction · 0.85
safeReadFileFunction · 0.85
extractVSCodeThemeFunction · 0.85
detectPlatformThemeFunction · 0.85

Tested by

no test coverage detected