Skip to content
This repository was archived by the owner on Jul 27, 2023. It is now read-only.

Commit 783558b

Browse files
committed
jsonValidation takes an array for fileMatch
1 parent 415c564 commit 783558b

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

src/jsonServerMain.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,13 @@ interface ISchemaAssociations {
2323
[pattern: string]: string[];
2424
}
2525

26+
interface ISchemaAssociation {
27+
fileMatch: string[];
28+
uri: string;
29+
}
30+
2631
namespace SchemaAssociationNotification {
27-
export const type: NotificationType<ISchemaAssociations, any> = new NotificationType('json/schemaAssociations');
32+
export const type: NotificationType<ISchemaAssociations | ISchemaAssociation[], any> = new NotificationType('json/schemaAssociations');
2833
}
2934

3035
namespace VSCodeContentRequest {
@@ -230,7 +235,7 @@ namespace LimitExceededWarnings {
230235
}
231236

232237
let jsonConfigurationSettings: JSONSchemaSettings[] | undefined = undefined;
233-
let schemaAssociations: ISchemaAssociations | undefined = undefined;
238+
let schemaAssociations: ISchemaAssociations | ISchemaAssociation[] | undefined = undefined;
234239
let formatterRegistration: Thenable<Disposable> | null = null;
235240

236241
// The settings have changed. Is send on server activation as well.
@@ -291,12 +296,16 @@ function updateConfiguration() {
291296
schemas: new Array<SchemaConfiguration>()
292297
};
293298
if (schemaAssociations) {
294-
for (const pattern in schemaAssociations) {
295-
const association = schemaAssociations[pattern];
296-
if (Array.isArray(association)) {
297-
association.forEach(uri => {
298-
languageSettings.schemas.push({ uri, fileMatch: [pattern] });
299-
});
299+
if (Array.isArray(schemaAssociations)) {
300+
Array.prototype.push.apply(languageSettings.schemas, schemaAssociations);
301+
} else {
302+
for (const pattern in schemaAssociations) {
303+
const association = schemaAssociations[pattern];
304+
if (Array.isArray(association)) {
305+
association.forEach(uri => {
306+
languageSettings.schemas.push({ uri, fileMatch: [pattern] });
307+
});
308+
}
300309
}
301310
}
302311
}

0 commit comments

Comments
 (0)