diff --git a/extensions/commands/theme-icons/index.ts b/extensions/commands/theme-icons/index.ts index 563fd7d..4c31aef 100644 --- a/extensions/commands/theme-icons/index.ts +++ b/extensions/commands/theme-icons/index.ts @@ -11,8 +11,7 @@ import { import { isAccent, getCustomSettings, - isMaterialTheme, - setCustomSetting + isMaterialTheme } from './../../helpers/settings'; import {getCurrentThemeID, setIconsID, getCurrentThemeIconsID, reloadWindow} from './../../helpers/vscode'; import {CHARSET} from './../../consts/files'; @@ -30,6 +29,8 @@ const replaceIconPathWithAccent = (iconPath: string, accentName: string): string return iconPath.replace('.svg', `.accent.${ accentName }.svg`); }; +let fixIconsRunning: boolean = false; + /** * Fix icons when flag auto-fix is active and current theme is Material */ @@ -40,6 +41,10 @@ export default async () => { deferred.reject = reject; }); + if (fixIconsRunning) { + return deferred.resolve(); + } + // Current theme id set on VSCode ("label" of the package.json) const themeLabel = getCurrentThemeID(); @@ -48,7 +53,7 @@ export default async () => { return deferred.resolve(); } - await setCustomSetting('fixIconsRunning', true); + fixIconsRunning = true; const DEFAULTS = getDefaultValues(); const CUSTOM_SETTINGS = getCustomSettings(); @@ -92,7 +97,7 @@ export default async () => { return; } - await setCustomSetting('fixIconsRunning', false); + fixIconsRunning = false; deferred.resolve(); }); diff --git a/extensions/helpers/configuration-change.ts b/extensions/helpers/configuration-change.ts index 2ce4074..537e401 100644 --- a/extensions/helpers/configuration-change.ts +++ b/extensions/helpers/configuration-change.ts @@ -1,17 +1,12 @@ import { ConfigurationChangeEvent } from 'vscode'; -import {getCustomSettings, isMaterialThemeIcons, isMaterialTheme} from './settings'; +import {isMaterialThemeIcons, isMaterialTheme} from './settings'; import {getCurrentThemeIconsID, getCurrentThemeID} from './vscode'; import handleAutoapply from './handle-autoapply'; const onIconsChanged = () => { - const customSettings = getCustomSettings(); - if (customSettings.fixIconsRunning) { - return; - } - const currentIconsTheme = getCurrentThemeIconsID(); return handleAutoapply(isMaterialThemeIcons(currentIconsTheme)); }; diff --git a/extensions/helpers/settings.ts b/extensions/helpers/settings.ts index c726015..ac4454b 100644 --- a/extensions/helpers/settings.ts +++ b/extensions/helpers/settings.ts @@ -66,7 +66,5 @@ export function setCustomSetting(settingName: string, value: any): Thenable { - const prevAccent = getAccent(); - return setCustomSetting('accentPrevious', prevAccent) - .then(() => setCustomSetting('accent', accentName)); + return setCustomSetting('accent', accentName); } diff --git a/extensions/interfaces/itheme-custom-properties.ts b/extensions/interfaces/itheme-custom-properties.ts index a836c2d..39b7c79 100644 --- a/extensions/interfaces/itheme-custom-properties.ts +++ b/extensions/interfaces/itheme-custom-properties.ts @@ -1,6 +1,4 @@ export interface IThemeCustomProperties { accent?: string; - accentPrevious?: string; autoApplyIcons?: boolean; - fixIconsRunning?: boolean; } diff --git a/package.json b/package.json index 9aa89e6..913e7ca 100644 --- a/package.json +++ b/package.json @@ -85,26 +85,39 @@ "properties": { "materialTheme.accent": { "type": "string", - "description": "Current accent color selected" - }, - "materialTheme.accentPrevious": { - "type": "string", - "description": "Previous accent color selected" + "default": "Blue", + "enum": [ + "Acid Lime", + "Blue", + "Breaking Bad", + "Bright Teal", + "Cyan", + "Graphite", + "Indigo", + "Lime", + "Orange", + "Pink", + "Purple", + "Red", + "Sky", + "Tomato", + "Teal", + "Yellow" + ], + "description": "Current accent color selected", + "scope": "window" }, "materialTheme.autoApplyIcons": { "type": "boolean", "description": "Enable/disable auto-apply of Material Theme icons with window reload when needed", - "default": false + "default": false, + "scope": "window" }, "materialTheme.showReloadNotification": { "type": "boolean", "description": "Useful when autoApplyIcons is false and you want to be asked to reload the window when needed", - "default": true - }, - "materialTheme.fixIconsRunning": { - "type": "boolean", - "description": "For checking if the command is currently acting", - "default": false + "default": true, + "scope": "window" } } },