Skip to content

Commit 1e2ea78

Browse files
committed
fix: handle when IDE theme is set to "system"
1 parent 905fcae commit 1e2ea78

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

cli/src/utils/theme-system.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,15 @@ const extractVSCodeTheme = (content: string): ThemeName | null => {
276276
}
277277

278278
const extractJetBrainsTheme = (content: string): ThemeName | null => {
279+
// Check if autodetect is enabled (Sync with OS setting)
280+
const autodetectMatch = content.match(
281+
/<component[^>]+name="LafManager"[^>]+autodetect="(true|false)"/i,
282+
)
283+
if (autodetectMatch?.[1]?.toLowerCase() === 'true') {
284+
// When syncing with OS, return null to trigger platform detection
285+
return null
286+
}
287+
279288
const normalized = content.toLowerCase()
280289
if (normalized.includes('darcula') || normalized.includes('dark')) {
281290
return 'dark'
@@ -371,6 +380,15 @@ const detectJetBrainsTheme = (): ThemeName | null => {
371380
if (theme) {
372381
return theme
373382
}
383+
384+
// If extractJetBrainsTheme returned null, check if autodetect is enabled
385+
// and fall back to platform detection
386+
const autodetectMatch = content.match(
387+
/<component[^>]+name="LafManager"[^>]+autodetect="(true|false)"/i,
388+
)
389+
if (autodetectMatch?.[1]?.toLowerCase() === 'true') {
390+
return detectPlatformTheme()
391+
}
374392
}
375393

376394
return null
@@ -390,6 +408,10 @@ const extractZedTheme = (content: string): ThemeName | null => {
390408
const modeRaw = themeConfig.mode
391409
if (typeof modeRaw === 'string') {
392410
const mode = modeRaw.toLowerCase()
411+
// If mode is 'system', return null to trigger platform detection
412+
if (mode === 'system') {
413+
return null
414+
}
393415
if (mode === 'dark' || mode === 'light') {
394416
candidates.push(mode)
395417
const modeTheme = themeConfig[mode]

0 commit comments

Comments
 (0)