From a43145646212a5d024fbc76eed4a928d650cb480 Mon Sep 17 00:00:00 2001 From: Akos Kitta Date: Fri, 31 Mar 2023 16:15:54 +0200 Subject: [PATCH] fix: update `themeId` settings after theme change In Theia, the theme ID is not always in sync with the persisted `workbench.colorTheme` preference value. For example, one can preview a theme with the `CtrlCmd+K` + `CtrlCmd+T` key chords. On quick pick selection change events, the theme changes, but the change is persisted only on accept (user presses `Enter`). IDE2 has its own way of showing and managing different settings in the UI. When the theme is changed from outside of the IDE2's UI, the model could get out of sync. This PR ensures that on `workbench.colorTheme` preference change, IDE2's settings model is synchronized with persisted Theia preferences. Closes #1987 Signed-off-by: Akos Kitta --- .../src/browser/dialogs/settings/settings.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arduino-ide-extension/src/browser/dialogs/settings/settings.ts b/arduino-ide-extension/src/browser/dialogs/settings/settings.ts index e4923c760..c120d6a9a 100644 --- a/arduino-ide-extension/src/browser/dialogs/settings/settings.ts +++ b/arduino-ide-extension/src/browser/dialogs/settings/settings.ts @@ -123,6 +123,17 @@ export class SettingsService { this._settings = deepClone(settings); this.ready.resolve(); }); + this.preferenceService.onPreferenceChanged(async (event) => { + await this.ready.promise; + const { preferenceName, newValue } = event; + if ( + preferenceName === 'workbench.colorTheme' && + typeof newValue === 'string' && + this._settings.themeId !== newValue + ) { + this.reset(); + } + }); } protected async loadSettings(): Promise {