Skip to content
Merged
Show file tree
Hide file tree
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
19 changes: 15 additions & 4 deletions src/languageserver/handlers/settingsHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,21 @@ export class SettingsHandler {

for (const schemaIndex in schemas.schemas) {
const schema = schemas.schemas[schemaIndex];

if (schema && schema.fileMatch) {
for (const fileMatch in schema.fileMatch) {
const currFileMatch: string = schema.fileMatch[fileMatch];
if (!schema.url) {
continue;
}
const fileMatches = schema.fileMatch ?? [];
if (fileMatches.length === 0) {
languageSettings.schemas.push({
uri: schema.url,
fileMatch: [],
priority: SchemaPriority.SchemaStore,
name: schema.name,
description: schema.description,
versions: schema.versions,
});
} else {
for (const currFileMatch of fileMatches) {
// If the schema is for files with a YAML extension, save the schema association
if (
this.yamlSettings.fileExtensions.findIndex((value) => {
Expand Down
31 changes: 31 additions & 0 deletions test/settingsHandlers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,37 @@ describe('Settings Handlers Tests', () => {
versions: undefined,
});
});
it('SettingsHandler should include schemas without file matches as selectable schemas', async () => {
const languageServerSetup = setupLanguageService({});
const languageService = languageServerSetup.languageService;
xhrStub.resolves({
responseText: `{"schemas": [
{
"name": "Traefik v3",
"description": "Traefik v3 YAML configuration file",
"url": "https://www.schemastore.org/traefik-v3.json"
}]}`,
});
const settingsHandler = new SettingsHandler(
connection,
languageService as unknown as LanguageService,
settingsState,
validationHandler as unknown as ValidationHandler,
{} as Telemetry
);
workspaceStub.getConfiguration.resolves([{}, {}, {}, {}]);
const configureSpy = sinon.stub(languageService, 'configure');
await settingsHandler.pullConfiguration();
configureSpy.restore();
expect(settingsState.schemaStoreSettings).deep.include({
uri: 'https://www.schemastore.org/traefik-v3.json',
fileMatch: [],
priority: SchemaPriority.SchemaStore,
name: 'Traefik v3',
description: 'Traefik v3 YAML configuration file',
versions: undefined,
});
});
});

it('SettingsHandler should not modify file match patterns', async () => {
Expand Down
Loading