Skip to content

Commit 4aa28a7

Browse files
authored
Merge pull request #115 from redhat-developer/disable_schema_store
Enabled/Disable schema store preference
2 parents 1458e25 + a614c7b commit 4aa28a7

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/server.ts

+18-2
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ interface Settings {
175175
hover: boolean;
176176
completion: boolean;
177177
customTags: Array<String>;
178+
schemaStore: {
179+
enable: boolean
180+
}
178181
};
179182
http: {
180183
proxy: string;
@@ -203,6 +206,7 @@ let yamlShouldHover = true;
203206
let yamlShouldCompletion = true;
204207
let schemaStoreSettings = [];
205208
let customTags = [];
209+
let schemaStoreEnabled = true;
206210

207211
connection.onDidChangeConfiguration((change) => {
208212
var settings = <Settings>change.settings;
@@ -215,6 +219,9 @@ connection.onDidChangeConfiguration((change) => {
215219
yamlShouldHover = settings.yaml.hover;
216220
yamlShouldCompletion = settings.yaml.completion;
217221
customTags = settings.yaml.customTags ? settings.yaml.customTags : [];
222+
if (settings.yaml.schemaStore) {
223+
schemaStoreEnabled = settings.yaml.schemaStore.enable;
224+
}
218225
if (settings.yaml.format) {
219226
yamlFormatterSettings = {
220227
singleQuote: settings.yaml.format.singleQuote || false,
@@ -241,12 +248,21 @@ connection.onDidChangeConfiguration((change) => {
241248
updateConfiguration();
242249
});
243250

244-
function setSchemaStoreSettingsIfNotSet(){
245-
if(schemaStoreSettings.length === 0){
251+
/**
252+
* This function helps set the schema store if it hasn't already been set
253+
* AND the schema store setting is enabled. If the schema store setting
254+
* is not enabled we need to clear the schemas.
255+
*/
256+
function setSchemaStoreSettingsIfNotSet() {
257+
const schemaStoreIsSet = (schemaStoreSettings.length !== 0);
258+
if (schemaStoreEnabled && !schemaStoreIsSet) {
246259
getSchemaStoreMatchingSchemas().then(schemaStore => {
247260
schemaStoreSettings = schemaStore.schemas;
248261
updateConfiguration();
249262
});
263+
} else if (!schemaStoreEnabled) {
264+
schemaStoreSettings = [];
265+
updateConfiguration();
250266
}
251267
}
252268

0 commit comments

Comments
 (0)