From 060ffc05919141f8eaa18c91c8ffab7d7ea363c2 Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Wed, 25 Mar 2020 17:50:24 +0100 Subject: [PATCH] #7 - Fix for excluding null values --- .vscode/launch.json | 2 +- .vscode/tasks.json | 8 ++++++++ src/commands/Settings.ts | 4 ++-- src/helpers/SettingsHelper.ts | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 506a69a2..819837ab 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -16,7 +16,7 @@ "outFiles": [ "${workspaceFolder}/dist/**/*.js" ], - "preLaunchTask": "npm: webpack" + // "preLaunchTask": "npm: webpack" }, { "name": "Extension Tests", diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 3b17e53b..1872cf03 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -15,6 +15,14 @@ "kind": "build", "isDefault": true } + }, + { + "type": "npm", + "script": "webpack", + "group": { + "kind": "build", + "isDefault": true + } } ] } diff --git a/src/commands/Settings.ts b/src/commands/Settings.ts index 0f880b3a..a0635964 100644 --- a/src/commands/Settings.ts +++ b/src/commands/Settings.ts @@ -123,7 +123,7 @@ export class Settings { crntTags = [...crntTags, ...tags]; // Update the tags and filter out the duplicates crntTags = [...new Set(crntTags)]; - crntTags = crntTags.sort(); + crntTags = crntTags.sort().filter(t => !!t); await config.update(SETTING_TAXONOMY_TAGS, crntTags); // Retrieve the currently known tags, and add the new ones @@ -132,7 +132,7 @@ export class Settings { crntCategories = [...crntCategories, ...categories]; // Update the categories and filter out the duplicates crntCategories = [...new Set(crntCategories)]; - crntCategories = crntCategories.sort(); + crntCategories = crntCategories.sort().filter(c => !!c); await config.update(SETTING_TAXONOMY_CATEGORIES, crntCategories); // Done diff --git a/src/helpers/SettingsHelper.ts b/src/helpers/SettingsHelper.ts index 070c764e..8397de99 100644 --- a/src/helpers/SettingsHelper.ts +++ b/src/helpers/SettingsHelper.ts @@ -31,7 +31,7 @@ export class SettingsHelper { const config = vscode.workspace.getConfiguration(CONFIG_KEY); const configSetting = type === TaxonomyType.Tag ? SETTING_TAXONOMY_TAGS : SETTING_TAXONOMY_CATEGORIES; options = [...new Set(options)]; - options = options.sort(); + options = options.sort().filter(o => !!o); await config.update(configSetting, options); } } \ No newline at end of file