Skip to content

Commit

Permalink
Merge pull request #115 from redhat-developer/disable_schema_store
Browse files Browse the repository at this point in the history
Enabled/Disable schema store preference
  • Loading branch information
JPinkney committed Feb 2, 2019
2 parents 1458e25 + a614c7b commit 4aa28a7
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/server.ts
Expand Up @@ -175,6 +175,9 @@ interface Settings {
hover: boolean;
completion: boolean;
customTags: Array<String>;
schemaStore: {
enable: boolean
}
};
http: {
proxy: string;
Expand Down Expand Up @@ -203,6 +206,7 @@ let yamlShouldHover = true;
let yamlShouldCompletion = true;
let schemaStoreSettings = [];
let customTags = [];
let schemaStoreEnabled = true;

connection.onDidChangeConfiguration((change) => {
var settings = <Settings>change.settings;
Expand All @@ -215,6 +219,9 @@ connection.onDidChangeConfiguration((change) => {
yamlShouldHover = settings.yaml.hover;
yamlShouldCompletion = settings.yaml.completion;
customTags = settings.yaml.customTags ? settings.yaml.customTags : [];
if (settings.yaml.schemaStore) {
schemaStoreEnabled = settings.yaml.schemaStore.enable;
}
if (settings.yaml.format) {
yamlFormatterSettings = {
singleQuote: settings.yaml.format.singleQuote || false,
Expand All @@ -241,12 +248,21 @@ connection.onDidChangeConfiguration((change) => {
updateConfiguration();
});

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();
}
}

Expand Down

0 comments on commit 4aa28a7

Please sign in to comment.