Skip to content

Commit

Permalink
fix: update themeId settings after theme change
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Akos Kitta committed Apr 13, 2023
1 parent ab5c63c commit a431456
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions arduino-ide-extension/src/browser/dialogs/settings/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down

0 comments on commit a431456

Please sign in to comment.