-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properly set default light and dark theme
- Concrete Theme will be derived from default OS theme - Remove built-in themes as soon as the actual theme is loaded
- Loading branch information
1 parent
4cb3ef9
commit 094e6ad
Showing
5 changed files
with
48 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2024 CrossBreeze. | ||
********************************************************************************/ | ||
|
||
import { BuiltinThemeProvider } from '@theia/core/lib/browser/theming'; | ||
import { injectable } from '@theia/core/shared/inversify'; | ||
import { ThemeServiceWithDB } from '@theia/monaco/lib/browser/monaco-indexed-db'; | ||
|
||
@injectable() | ||
export class CrossModelThemeService extends ThemeServiceWithDB { | ||
override setCurrentTheme(themeId: string, persist?: boolean): void { | ||
super.setCurrentTheme(themeId, persist); | ||
this.removeBuiltInThemes(themeId); | ||
} | ||
|
||
protected removeBuiltInThemes(themeId: string): void { | ||
if (!this.tryGetTheme(BuiltinThemeProvider.themes[0].id)) { | ||
// the built-in themes are already removed | ||
return; | ||
} | ||
const configuredTheme = this.getConfiguredTheme(); | ||
if (configuredTheme && configuredTheme.id === themeId) { | ||
// remove built-in themes as soon as we have the configured theme ready, which may be loaded delayed through an extension | ||
BuiltinThemeProvider.themes.forEach(theme => this.register(theme).dispose()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2024 CrossBreeze. | ||
********************************************************************************/ | ||
import { ContainerModule } from '@theia/core/shared/inversify'; | ||
import { ThemeServiceWithDB } from '@theia/monaco/lib/browser/monaco-indexed-db'; | ||
import { CrossModelThemeService } from './cross-model-theme-service'; | ||
|
||
export default new ContainerModule((bind, _unbind, _isBound, rebind) => { | ||
bind(CrossModelThemeService).toSelf().inSingletonScope(); | ||
rebind(ThemeServiceWithDB).toService(CrossModelThemeService); | ||
}); |