Skip to content

Commit 4d37840

Browse files
Copilotalexr00
andcommitted
Simplify optional chaining logic in color getter functions
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent fef8242 commit 4d37840

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/view/theme.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,17 @@ function getCurrentThemePaths(themeName: string): vscode.Uri | undefined {
7474
}
7575

7676
export function getIconForeground(themeData: ThemeData | undefined, kind: 'light' | 'dark'): string {
77-
return (themeData?.colors ? themeData.colors['icon.foreground'] : undefined) ?? (kind === 'dark' ? '#C5C5C5' : '#424242');
77+
return themeData?.colors?.['icon.foreground'] ?? (kind === 'dark' ? '#C5C5C5' : '#424242');
7878
}
7979

8080
export function getListWarningForeground(themeData: ThemeData | undefined, kind: 'light' | 'dark'): string {
81-
return (themeData?.colors ? themeData.colors['list.warningForeground'] : undefined) ?? (kind === 'dark' ? '#CCA700' : '#855F00');
81+
return themeData?.colors?.['list.warningForeground'] ?? (kind === 'dark' ? '#CCA700' : '#855F00');
8282
}
8383

8484
export function getListErrorForeground(themeData: ThemeData | undefined, kind: 'light' | 'dark'): string {
85-
return (themeData?.colors ? themeData.colors['list.errorForeground'] : undefined) ?? (kind === 'dark' ? '#F88070' : '#B01011');
85+
return themeData?.colors?.['list.errorForeground'] ?? (kind === 'dark' ? '#F88070' : '#B01011');
8686
}
8787

8888
export function getNotebookStatusSuccessIconForeground(themeData: ThemeData | undefined, kind: 'light' | 'dark'): string {
89-
return (themeData?.colors ? themeData.colors['notebookStatusSuccessIcon.foreground'] : undefined) ?? (kind === 'dark' ? '#89D185' : '#388A34');
89+
return themeData?.colors?.['notebookStatusSuccessIcon.foreground'] ?? (kind === 'dark' ? '#89D185' : '#388A34');
9090
}

0 commit comments

Comments
 (0)