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

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

Conversation

dsherret
Copy link
Contributor

@dsherret dsherret commented Sep 5, 2021

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

Closes #106

@@ -273,6 +273,9 @@ export class JSONSchemaService implements IJSONSchemaService {
}

public onResourceChange(uri: string): boolean {
// always clear this local cache when a resource changes
this.cachedSchemaForResource = undefined;
Copy link
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.


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

@dsherret dsherret Sep 5, 2021

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
Copy link
Contributor

aeschli commented Sep 27, 2021

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