Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bc3cb0c

Browse files
authored
Save preferences in sequence (#856)
1 parent 473cb11 commit bc3cb0c

File tree

1 file changed

+26
-61
lines changed
  • arduino-ide-extension/src/browser/dialogs/settings

1 file changed

+26
-61
lines changed

‎arduino-ide-extension/src/browser/dialogs/settings/settings.tsx‎

Lines changed: 26 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { injectable, inject, postConstruct } from 'inversify';
22
import URI from '@theia/core/lib/common/uri';
33
import { Emitter } from '@theia/core/lib/common/event';
4-
import { Deferred } from '@theia/core/lib/common/promise-util';
4+
import { Deferred,timeout } from '@theia/core/lib/common/promise-util';
55
import { deepClone } from '@theia/core/lib/common/objects';
66
import { FileService } from '@theia/filesystem/lib/browser/file-service';
77
import { ThemeService } from '@theia/core/lib/browser/theming';
@@ -217,6 +217,11 @@ export class SettingsService {
217217
}
218218
}
219219

220+
private async savePreference(name: string, value: unknown): Promise<void> {
221+
await this.preferenceService.set(name, value, PreferenceScope.User);
222+
await timeout(5);
223+
}
224+
220225
async save(): Promise<string | true> {
221226
await this.ready.promise;
222227
const {
@@ -245,69 +250,29 @@ export class SettingsService {
245250
(config as any).network = network;
246251
(config as any).locale = currentLanguage;
247252

248-
await Promise.all([
249-
this.preferenceService.set(
250-
'editor.fontSize',
251-
editorFontSize,
252-
PreferenceScope.User
253-
),
254-
this.preferenceService.set(
255-
'workbench.colorTheme',
256-
themeId,
257-
PreferenceScope.User
258-
),
259-
this.preferenceService.set(
260-
'editor.autoSave',
261-
autoSave,
262-
PreferenceScope.User
263-
),
264-
this.preferenceService.set(
265-
'editor.quickSuggestions',
266-
quickSuggestions,
267-
PreferenceScope.User
268-
),
269-
this.preferenceService.set(
270-
AUTO_SCALE_SETTING,
271-
autoScaleInterface,
272-
PreferenceScope.User
273-
),
274-
this.preferenceService.set(
275-
ZOOM_LEVEL_SETTING,
276-
interfaceScale,
277-
PreferenceScope.User
278-
),
279-
this.preferenceService.set(
280-
COMPILE_VERBOSE_SETTING,
281-
verboseOnCompile,
282-
PreferenceScope.User
283-
),
284-
this.preferenceService.set(
285-
COMPILE_WARNINGS_SETTING,
286-
compilerWarnings,
287-
PreferenceScope.User
288-
),
289-
this.preferenceService.set(
290-
UPLOAD_VERBOSE_SETTING,
291-
verboseOnUpload,
292-
PreferenceScope.User
293-
),
294-
this.preferenceService.set(
295-
UPLOAD_VERIFY_SETTING,
296-
verifyAfterUpload,
297-
PreferenceScope.User
298-
),
299-
this.preferenceService.set(
300-
SHOW_ALL_FILES_SETTING,
301-
sketchbookShowAllFiles,
302-
PreferenceScope.User
303-
),
304-
this.configService.setConfiguration(config),
305-
]);
253+
await this.savePreference('editor.fontSize', editorFontSize);
254+
await this.savePreference('workbench.colorTheme', themeId);
255+
await this.savePreference('editor.autoSave', autoSave);
256+
await this.savePreference('editor.quickSuggestions', quickSuggestions);
257+
await this.savePreference(AUTO_SCALE_SETTING, autoScaleInterface);
258+
await this.savePreference(ZOOM_LEVEL_SETTING, interfaceScale);
259+
await this.savePreference(ZOOM_LEVEL_SETTING, interfaceScale);
260+
await this.savePreference(COMPILE_VERBOSE_SETTING, verboseOnCompile);
261+
await this.savePreference(COMPILE_WARNINGS_SETTING, compilerWarnings);
262+
await this.savePreference(UPLOAD_VERBOSE_SETTING, verboseOnUpload);
263+
await this.savePreference(UPLOAD_VERIFY_SETTING, verifyAfterUpload);
264+
await this.savePreference(SHOW_ALL_FILES_SETTING, sketchbookShowAllFiles);
265+
await this.configService.setConfiguration(config);
306266
this.onDidChangeEmitter.fire(this._settings);
307267

308268
// after saving all the settings, if we need to change the language we need to perform a reload
309-
if (currentLanguage !== nls.locale) {
310-
window.localStorage.setItem(nls.localeId, currentLanguage);
269+
// Only reload if the language differs from the current locale. `nls.locale === undefined` signals english as well
270+
if (currentLanguage !== nls.locale && !(currentLanguage === 'en' && nls.locale === undefined)) {
271+
if (currentLanguage === 'en') {
272+
window.localStorage.removeItem(nls.localeId);
273+
} else {
274+
window.localStorage.setItem(nls.localeId, currentLanguage);
275+
}
311276
window.location.reload();
312277
}
313278

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /