Skip to content

Commit 4a6f60b

Browse files
committed
dynamic schemas not updated. Fixes microsoft#79363
1 parent 3eaa4e8 commit 4a6f60b

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

  • extensions/json-language-features/client/src

extensions/json-language-features/client/src/jsonMain.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,14 @@ export function activate(context: ExtensionContext) {
145145
}
146146
});
147147

148+
const schemaDocuments: { [uri: string]: boolean } = {};
149+
148150
// handle content request
149151
client.onRequest(VSCodeContentRequest.type, (uriPath: string) => {
150152
let uri = Uri.parse(uriPath);
151153
if (uri.scheme !== 'http' && uri.scheme !== 'https') {
152154
return workspace.openTextDocument(uri).then(doc => {
155+
schemaDocuments[uri.toString()] = true;
153156
return doc.getText();
154157
}, error => {
155158
return Promise.reject(error);
@@ -164,10 +167,12 @@ export function activate(context: ExtensionContext) {
164167
}
165168
});
166169

167-
let handleContentChange = (uri: Uri) => {
168-
if (uri.scheme === 'vscode' && uri.authority === 'schemas') {
169-
client.sendNotification(SchemaContentChangeNotification.type, uri.toString());
170+
let handleContentChange = (uriString: string) => {
171+
if (schemaDocuments[uriString]) {
172+
client.sendNotification(SchemaContentChangeNotification.type, uriString);
173+
return true;
170174
}
175+
return false;
171176
};
172177

173178
let handleActiveEditorChange = (activeEditor?: TextEditor) => {
@@ -184,10 +189,13 @@ export function activate(context: ExtensionContext) {
184189
}
185190
};
186191

187-
toDispose.push(workspace.onDidChangeTextDocument(e => handleContentChange(e.document.uri)));
192+
toDispose.push(workspace.onDidChangeTextDocument(e => handleContentChange(e.document.uri.toString())));
188193
toDispose.push(workspace.onDidCloseTextDocument(d => {
189-
handleContentChange(d.uri);
190-
fileSchemaErrors.delete(d.uri.toString());
194+
const uriString = d.uri.toString();
195+
if (handleContentChange(uriString)) {
196+
delete schemaDocuments[uriString];
197+
}
198+
fileSchemaErrors.delete(uriString);
191199
}));
192200
toDispose.push(window.onDidChangeActiveTextEditor(handleActiveEditorChange));
193201

0 commit comments

Comments
 (0)