Can't use basic string as schema URI. Fixes microsoft/monaco-editor#2683
This commit is contained in:
Родитель
971dc54088
Коммит
6a3406c5f4
|
@ -339,7 +339,7 @@ export class JSONSchemaService implements IJSONSchemaService {
|
|||
this.cachedSchemaForResource = undefined;
|
||||
|
||||
if (filePatterns) {
|
||||
this.addFilePatternAssociation(filePatterns, [uri]);
|
||||
this.addFilePatternAssociation(filePatterns, [id]);
|
||||
}
|
||||
return unresolvedSchemaContent ? this.addSchemaHandle(id, unresolvedSchemaContent) : this.getOrAddSchemaHandle(id);
|
||||
}
|
||||
|
|
|
@ -383,6 +383,33 @@ suite('JSON Schema', () => {
|
|||
});
|
||||
});
|
||||
|
||||
test('Preloaded Schema, string as URI', async function () {
|
||||
// for https://github.com/microsoft/monaco-editor/issues/2683
|
||||
const service = new SchemaService.JSONSchemaService(newMockRequestService(), workspaceContext);
|
||||
const id = 'a5f8f39b-c7ee-48f8-babe-b7146ed3c055';
|
||||
const schema: JSONSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
child: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
'grandchild': {
|
||||
type: 'number',
|
||||
description: 'Meaning of Life'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
service.registerExternalSchema(id, ['*.json'], schema);
|
||||
|
||||
return service.getSchemaForResource('test.json').then((schema) => {
|
||||
const section = schema?.getSection(['child', 'grandchild']);
|
||||
assert.equal(section?.description, 'Meaning of Life');
|
||||
});
|
||||
});
|
||||
|
||||
test('Multiple matches', async function () {
|
||||
const service = new SchemaService.JSONSchemaService(newMockRequestService(), workspaceContext);
|
||||
const id1 = 'https://myschemastore/test1';
|
||||
|
|
Загрузка…
Ссылка в новой задаче