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 <a.kitta@arduino.cc>
This commit is contained in:
Akos Kitta 2023-03-31 16:15:54 +02:00 committed by Akos Kitta
parent 96da5bb5ea
commit cb2a371263

View File

@ -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<Settings> {