From c3a9b953734f92521cd334544c049c5436a0b7e8 Mon Sep 17 00:00:00 2001 From: jpinkney Date: Sun, 30 Dec 2018 22:47:48 -0500 Subject: [PATCH 1/2] Enabled/Disable schema store preference --- src/server.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/server.ts b/src/server.ts index 4fa0f255..035ff671 100755 --- a/src/server.ts +++ b/src/server.ts @@ -184,6 +184,7 @@ interface Settings { hover: boolean; completion: boolean; customTags: Array; + schemaStore: boolean; }; http: { proxy: string; @@ -212,6 +213,7 @@ let yamlShouldHover = true; let yamlShouldCompletion = true; let schemaStoreSettings = []; let customTags = []; +let schemaStoreEnabled = true; connection.onDidChangeConfiguration((change) => { var settings = change.settings; @@ -224,6 +226,7 @@ connection.onDidChangeConfiguration((change) => { yamlShouldHover = settings.yaml.hover; yamlShouldCompletion = settings.yaml.completion; customTags = settings.yaml.customTags ? settings.yaml.customTags : []; + schemaStoreEnabled = settings.yaml.schemaStore; if (settings.yaml.format) { yamlFormatterSettings = { singleQuote: settings.yaml.format.singleQuote || false, @@ -263,12 +266,21 @@ connection.onDidChangeConfiguration((change) => { } }); -function setSchemaStoreSettingsIfNotSet(){ - if(schemaStoreSettings.length === 0){ +/** + * This function helps set the schema store if it hasn't already been set + * AND the schema store setting is enabled. If the schema store setting + * is not enabled we need to clear the schemas. + */ +function setSchemaStoreSettingsIfNotSet() { + const schemaStoreIsSet = (schemaStoreSettings.length !== 0); + if (schemaStoreEnabled && !schemaStoreIsSet) { getSchemaStoreMatchingSchemas().then(schemaStore => { schemaStoreSettings = schemaStore.schemas; updateConfiguration(); }); + } else if (!schemaStoreEnabled) { + schemaStoreSettings = []; + updateConfiguration(); } } From a614c7bdb659c8e05b947d831317d8239072c4f7 Mon Sep 17 00:00:00 2001 From: jpinkney Date: Mon, 7 Jan 2019 15:54:42 -0500 Subject: [PATCH 2/2] Fixup --- src/server.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/server.ts b/src/server.ts index 035ff671..c13523c0 100755 --- a/src/server.ts +++ b/src/server.ts @@ -184,7 +184,9 @@ interface Settings { hover: boolean; completion: boolean; customTags: Array; - schemaStore: boolean; + schemaStore: { + enable: boolean + } }; http: { proxy: string; @@ -226,7 +228,9 @@ connection.onDidChangeConfiguration((change) => { yamlShouldHover = settings.yaml.hover; yamlShouldCompletion = settings.yaml.completion; customTags = settings.yaml.customTags ? settings.yaml.customTags : []; - schemaStoreEnabled = settings.yaml.schemaStore; + if (settings.yaml.schemaStore) { + schemaStoreEnabled = settings.yaml.schemaStore.enable; + } if (settings.yaml.format) { yamlFormatterSettings = { singleQuote: settings.yaml.format.singleQuote || false,