From 658c19f55be2c5edc55f551260f1460c7c2cc533 Mon Sep 17 00:00:00 2001 From: Alberto Iannaccone Date: Thu, 2 Sep 2021 11:50:04 +0100 Subject: [PATCH] [ATL-1571] Fix editor quick suggestions preference (#494) * Fix editor quick suggestions preference * little settings refactoring --- .../src/browser/settings.tsx | 79 +++++++++++-------- 1 file changed, 48 insertions(+), 31 deletions(-) diff --git a/arduino-ide-extension/src/browser/settings.tsx b/arduino-ide-extension/src/browser/settings.tsx index 5004732e4..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,32 +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>( - 'editor.quickSuggestion', - { - 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<'on' | 'off'>(AUTO_SAVE_SETTING, 'on'), + this.preferenceService.get< + Record<'other' | 'comments' | 'strings', boolean> + >(QUICK_SUGGESTIONS_SETTING, { + other: false, + comments: false, + strings: 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; @@ -257,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 ),