Skip to content

fix: clear JsonSchemaService local single resource cache on schema change#105

Merged
aeschli merged 1 commit into
microsoft:mainfrom
dsherret:clear-json-schema-service-local-single-resource-cache
Sep 27, 2021
Merged

fix: clear JsonSchemaService local single resource cache on schema change#105
aeschli merged 1 commit into
microsoft:mainfrom
dsherret:clear-json-schema-service-local-single-resource-cache

Conversation

@dsherret

@dsherret dsherret commented Sep 5, 2021

Copy link
Copy Markdown
Contributor

This local cache was not being cleared on a resource change.

Closes #106


public onResourceChange(uri: string): boolean {
// always clear this local cache when a resource changes
this.cachedSchemaForResource = undefined;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this could be more fine targeted, but I'm not sure it's worth the complexity.

Comment thread src/test/schema.test.ts

// now ensure validation occurs with the new schema
validation = await ls.doValidation(testDoc.textDoc, testDoc.jsonDoc);
assert.deepStrictEqual(validation.map(v => v.message), []);

@dsherret dsherret Sep 5, 2021

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously this would use the resource on this.cachedSchemaForResource instead of the latest cache so it would get the previous diagnostics.

@aeschli

aeschli commented Sep 27, 2021

Copy link
Copy Markdown
Collaborator

Thanks a lot @dsherret !

@aeschli aeschli added this to the September 2021 milestone Sep 27, 2021
@aeschli aeschli self-assigned this Sep 27, 2021
@dsherret dsherret deleted the clear-json-schema-service-local-single-resource-cache branch September 28, 2021 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dynamic schema does not update when changing for current document and not using $schema property

2 participants