Skip to content

Commit 658c19f

Browse files
author
Alberto Iannaccone
authored
[ATL-1571] Fix editor quick suggestions preference (#494)
* Fix editor quick suggestions preference * little settings refactoring
1 parent 3f8a076 commit 658c19f

File tree

1 file changed

+48
-31
lines changed

1 file changed

+48
-31
lines changed

Diff for: arduino-ide-extension/src/browser/settings.tsx

+48-31
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,27 @@ import {
3434
ProxySettings,
3535
} from '../common/protocol';
3636

37+
const EDITOR_SETTING = 'editor';
38+
const FONT_SIZE_SETTING = `${EDITOR_SETTING}.fontSize`;
39+
const AUTO_SAVE_SETTING = `${EDITOR_SETTING}.autoSave`;
40+
const QUICK_SUGGESTIONS_SETTING = `${EDITOR_SETTING}.quickSuggestions`;
41+
const ARDUINO_SETTING = 'arduino';
42+
const WINDOW_SETTING = `${ARDUINO_SETTING}.window`;
43+
// const IDE_SETTING = `${ARDUINO_SETTING}.ide`;
44+
const COMPILE_SETTING = `${ARDUINO_SETTING}.compile`;
45+
const UPLOAD_SETTING = `${ARDUINO_SETTING}.upload`;
46+
const LANGUAGE_SETTING = `${ARDUINO_SETTING}.language`;
47+
const SKETCHBOOK_SETTING = `${ARDUINO_SETTING}.sketchbook`;
48+
const AUTO_SCALE_SETTING = `${WINDOW_SETTING}.autoScale`;
49+
const ZOOM_LEVEL_SETTING = `${WINDOW_SETTING}.zoomLevel`;
50+
// const AUTO_UPDATE_SETTING = `${IDE_SETTING}.autoUpdate`;
51+
const COMPILE_VERBOSE_SETTING = `${COMPILE_SETTING}.verbose`;
52+
const COMPILE_WARNINGS_SETTING = `${COMPILE_SETTING}.warnings`;
53+
const UPLOAD_VERBOSE_SETTING = `${UPLOAD_SETTING}.verbose`;
54+
const UPLOAD_VERIFY_SETTING = `${UPLOAD_SETTING}.verify`;
55+
const LANGUAGE_LOG_SETTING = `${LANGUAGE_SETTING}.log`;
56+
const SHOW_ALL_FILES_SETTING = `${SKETCHBOOK_SETTING}.showAllFiles`;
57+
3758
export interface Settings extends Index {
3859
editorFontSize: number; // `editor.fontSize`
3960
themeId: string; // `workbench.colorTheme`
@@ -109,32 +130,28 @@ export class SettingsService {
109130
sketchbookShowAllFiles,
110131
cliConfig,
111132
] = await Promise.all([
112-
this.preferenceService.get<number>('editor.fontSize', 12),
133+
this.preferenceService.get<number>(FONT_SIZE_SETTING, 12),
113134
this.preferenceService.get<string>(
114135
'workbench.colorTheme',
115136
'arduino-theme'
116137
),
117-
this.preferenceService.get<'on' | 'off'>('editor.autoSave', 'on'),
118-
this.preferenceService.get<Record<string, unknown>>(
119-
'editor.quickSuggestion',
120-
{
121-
other: false,
122-
comments: false,
123-
strings: false,
124-
}
125-
),
126-
this.preferenceService.get<boolean>('arduino.window.autoScale', true),
127-
this.preferenceService.get<number>('arduino.window.zoomLevel', 0),
128-
// this.preferenceService.get<string>('arduino.ide.autoUpdate', true),
129-
this.preferenceService.get<boolean>('arduino.compile.verbose', true),
130-
this.preferenceService.get<any>('arduino.compile.warnings', 'None'),
131-
this.preferenceService.get<boolean>('arduino.upload.verbose', true),
132-
this.preferenceService.get<boolean>('arduino.upload.verify', true),
133-
this.preferenceService.get<boolean>('arduino.language.log', true),
134-
this.preferenceService.get<boolean>(
135-
'arduino.sketchbook.showAllFiles',
136-
false
137-
),
138+
this.preferenceService.get<'on' | 'off'>(AUTO_SAVE_SETTING, 'on'),
139+
this.preferenceService.get<
140+
Record<'other' | 'comments' | 'strings', boolean>
141+
>(QUICK_SUGGESTIONS_SETTING, {
142+
other: false,
143+
comments: false,
144+
strings: false,
145+
}),
146+
this.preferenceService.get<boolean>(AUTO_SCALE_SETTING, true),
147+
this.preferenceService.get<number>(ZOOM_LEVEL_SETTING, 0),
148+
// this.preferenceService.get<string>(AUTO_UPDATE_SETTING, true),
149+
this.preferenceService.get<boolean>(COMPILE_VERBOSE_SETTING, true),
150+
this.preferenceService.get<any>(COMPILE_WARNINGS_SETTING, 'None'),
151+
this.preferenceService.get<boolean>(UPLOAD_VERBOSE_SETTING, true),
152+
this.preferenceService.get<boolean>(UPLOAD_VERIFY_SETTING, true),
153+
this.preferenceService.get<boolean>(LANGUAGE_LOG_SETTING, true),
154+
this.preferenceService.get<boolean>(SHOW_ALL_FILES_SETTING, false),
138155
this.configService.getConfiguration(),
139156
]);
140157
const { additionalUrls, sketchDirUri, network } = cliConfig;
@@ -257,43 +274,43 @@ export class SettingsService {
257274
PreferenceScope.User
258275
),
259276
this.preferenceService.set(
260-
'arduino.window.autoScale',
277+
AUTO_SCALE_SETTING,
261278
autoScaleInterface,
262279
PreferenceScope.User
263280
),
264281
this.preferenceService.set(
265-
'arduino.window.zoomLevel',
282+
ZOOM_LEVEL_SETTING,
266283
interfaceScale,
267284
PreferenceScope.User
268285
),
269-
// this.preferenceService.set('arduino.ide.autoUpdate', checkForUpdates, PreferenceScope.User),
286+
// this.preferenceService.set(AUTO_UPDATE_SETTING, checkForUpdates, PreferenceScope.User),
270287
this.preferenceService.set(
271-
'arduino.compile.verbose',
288+
COMPILE_VERBOSE_SETTING,
272289
verboseOnCompile,
273290
PreferenceScope.User
274291
),
275292
this.preferenceService.set(
276-
'arduino.compile.warnings',
293+
COMPILE_WARNINGS_SETTING,
277294
compilerWarnings,
278295
PreferenceScope.User
279296
),
280297
this.preferenceService.set(
281-
'arduino.upload.verbose',
298+
UPLOAD_VERBOSE_SETTING,
282299
verboseOnUpload,
283300
PreferenceScope.User
284301
),
285302
this.preferenceService.set(
286-
'arduino.upload.verify',
303+
UPLOAD_VERIFY_SETTING,
287304
verifyAfterUpload,
288305
PreferenceScope.User
289306
),
290307
this.preferenceService.set(
291-
'arduino.language.log',
308+
LANGUAGE_LOG_SETTING,
292309
enableLsLogs,
293310
PreferenceScope.User
294311
),
295312
this.preferenceService.set(
296-
'arduino.sketchbook.showAllFiles',
313+
SHOW_ALL_FILES_SETTING,
297314
sketchbookShowAllFiles,
298315
PreferenceScope.User
299316
),

0 commit comments

Comments
 (0)