Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabled/Disable schema store preference #115

Merged
merged 2 commits into from
Feb 2, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ interface Settings {
hover: boolean;
completion: boolean;
customTags: Array<String>;
schemaStore: {
enable: boolean
}
};
http: {
proxy: string;
Expand Down Expand Up @@ -212,6 +215,7 @@ let yamlShouldHover = true;
let yamlShouldCompletion = true;
let schemaStoreSettings = [];
let customTags = [];
let schemaStoreEnabled = true;

connection.onDidChangeConfiguration((change) => {
var settings = <Settings>change.settings;
Expand All @@ -224,6 +228,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 Down Expand Up @@ -263,12 +270,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();
}
}

Expand Down