From 1e20c45a8973907580d224a7c8848c69ce82ef4d Mon Sep 17 00:00:00 2001 From: Alberto Iannaccone Date: Tue, 31 Aug 2021 13:49:07 +0100 Subject: [PATCH 1/2] Fix editor quick suggestions preference --- arduino-ide-extension/src/browser/settings.tsx | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/arduino-ide-extension/src/browser/settings.tsx b/arduino-ide-extension/src/browser/settings.tsx index 5004732e4..50bc61d7f 100644 --- a/arduino-ide-extension/src/browser/settings.tsx +++ b/arduino-ide-extension/src/browser/settings.tsx @@ -115,14 +115,13 @@ export class SettingsService { 'arduino-theme' ), this.preferenceService.get<'on' | 'off'>('editor.autoSave', 'on'), - this.preferenceService.get>( - 'editor.quickSuggestion', - { - other: false, - comments: false, - strings: false, - } - ), + this.preferenceService.get< + Record<'other' | 'comments' | 'strings', boolean> + >('editor.quickSuggestions', { + other: false, + comments: false, + strings: false, + }), this.preferenceService.get('arduino.window.autoScale', true), this.preferenceService.get('arduino.window.zoomLevel', 0), // this.preferenceService.get('arduino.ide.autoUpdate', true), From efa9f6a8b56bc055831440f7e517eb9cec44d44d Mon Sep 17 00:00:00 2001 From: Alberto Iannaccone Date: Wed, 1 Sep 2021 11:14:34 +0100 Subject: [PATCH 2/2] little settings refactoring --- .../src/browser/settings.tsx | 66 ++++++++++++------- 1 file changed, 42 insertions(+), 24 deletions(-) diff --git a/arduino-ide-extension/src/browser/settings.tsx b/arduino-ide-extension/src/browser/settings.tsx index 50bc61d7f..07ab229fd 100644 --- a/arduino-ide-extension/src/browser/settings.tsx +++ b/arduino-ide-extension/src/browser/settings.tsx @@ -34,6 +34,27 @@ import { ProxySettings, } from '../common/protocol'; +const EDITOR_SETTING = 'editor'; +const FONT_SIZE_SETTING = `${EDITOR_SETTING}.fontSize`; +const AUTO_SAVE_SETTING = `${EDITOR_SETTING}.autoSave`; +const QUICK_SUGGESTIONS_SETTING = `${EDITOR_SETTING}.quickSuggestions`; +const ARDUINO_SETTING = 'arduino'; +const WINDOW_SETTING = `${ARDUINO_SETTING}.window`; +// const IDE_SETTING = `${ARDUINO_SETTING}.ide`; +const COMPILE_SETTING = `${ARDUINO_SETTING}.compile`; +const UPLOAD_SETTING = `${ARDUINO_SETTING}.upload`; +const LANGUAGE_SETTING = `${ARDUINO_SETTING}.language`; +const SKETCHBOOK_SETTING = `${ARDUINO_SETTING}.sketchbook`; +const AUTO_SCALE_SETTING = `${WINDOW_SETTING}.autoScale`; +const ZOOM_LEVEL_SETTING = `${WINDOW_SETTING}.zoomLevel`; +// const AUTO_UPDATE_SETTING = `${IDE_SETTING}.autoUpdate`; +const COMPILE_VERBOSE_SETTING = `${COMPILE_SETTING}.verbose`; +const COMPILE_WARNINGS_SETTING = `${COMPILE_SETTING}.warnings`; +const UPLOAD_VERBOSE_SETTING = `${UPLOAD_SETTING}.verbose`; +const UPLOAD_VERIFY_SETTING = `${UPLOAD_SETTING}.verify`; +const LANGUAGE_LOG_SETTING = `${LANGUAGE_SETTING}.log`; +const SHOW_ALL_FILES_SETTING = `${SKETCHBOOK_SETTING}.showAllFiles`; + export interface Settings extends Index { editorFontSize: number; // `editor.fontSize` themeId: string; // `workbench.colorTheme` @@ -109,31 +130,28 @@ export class SettingsService { sketchbookShowAllFiles, cliConfig, ] = await Promise.all([ - this.preferenceService.get('editor.fontSize', 12), + this.preferenceService.get(FONT_SIZE_SETTING, 12), this.preferenceService.get( 'workbench.colorTheme', 'arduino-theme' ), - this.preferenceService.get<'on' | 'off'>('editor.autoSave', 'on'), + this.preferenceService.get<'on' | 'off'>(AUTO_SAVE_SETTING, 'on'), this.preferenceService.get< Record<'other' | 'comments' | 'strings', boolean> - >('editor.quickSuggestions', { + >(QUICK_SUGGESTIONS_SETTING, { other: false, comments: false, strings: false, }), - this.preferenceService.get('arduino.window.autoScale', true), - this.preferenceService.get('arduino.window.zoomLevel', 0), - // this.preferenceService.get('arduino.ide.autoUpdate', true), - this.preferenceService.get('arduino.compile.verbose', true), - this.preferenceService.get('arduino.compile.warnings', 'None'), - this.preferenceService.get('arduino.upload.verbose', true), - this.preferenceService.get('arduino.upload.verify', true), - this.preferenceService.get('arduino.language.log', true), - this.preferenceService.get( - 'arduino.sketchbook.showAllFiles', - false - ), + this.preferenceService.get(AUTO_SCALE_SETTING, true), + this.preferenceService.get(ZOOM_LEVEL_SETTING, 0), + // this.preferenceService.get(AUTO_UPDATE_SETTING, true), + this.preferenceService.get(COMPILE_VERBOSE_SETTING, true), + this.preferenceService.get(COMPILE_WARNINGS_SETTING, 'None'), + this.preferenceService.get(UPLOAD_VERBOSE_SETTING, true), + this.preferenceService.get(UPLOAD_VERIFY_SETTING, true), + this.preferenceService.get(LANGUAGE_LOG_SETTING, true), + this.preferenceService.get(SHOW_ALL_FILES_SETTING, false), this.configService.getConfiguration(), ]); const { additionalUrls, sketchDirUri, network } = cliConfig; @@ -256,43 +274,43 @@ export class SettingsService { PreferenceScope.User ), this.preferenceService.set( - 'arduino.window.autoScale', + AUTO_SCALE_SETTING, autoScaleInterface, PreferenceScope.User ), this.preferenceService.set( - 'arduino.window.zoomLevel', + ZOOM_LEVEL_SETTING, interfaceScale, PreferenceScope.User ), - // this.preferenceService.set('arduino.ide.autoUpdate', checkForUpdates, PreferenceScope.User), + // this.preferenceService.set(AUTO_UPDATE_SETTING, checkForUpdates, PreferenceScope.User), this.preferenceService.set( - 'arduino.compile.verbose', + COMPILE_VERBOSE_SETTING, verboseOnCompile, PreferenceScope.User ), this.preferenceService.set( - 'arduino.compile.warnings', + COMPILE_WARNINGS_SETTING, compilerWarnings, PreferenceScope.User ), this.preferenceService.set( - 'arduino.upload.verbose', + UPLOAD_VERBOSE_SETTING, verboseOnUpload, PreferenceScope.User ), this.preferenceService.set( - 'arduino.upload.verify', + UPLOAD_VERIFY_SETTING, verifyAfterUpload, PreferenceScope.User ), this.preferenceService.set( - 'arduino.language.log', + LANGUAGE_LOG_SETTING, enableLsLogs, PreferenceScope.User ), this.preferenceService.set( - 'arduino.sketchbook.showAllFiles', + SHOW_ALL_FILES_SETTING, sketchbookShowAllFiles, PreferenceScope.User ),