diff --git a/language-server/src/features/document-settings.js b/language-server/src/features/document-settings.js index 9f368cd..64e4b89 100644 --- a/language-server/src/features/document-settings.js +++ b/language-server/src/features/document-settings.js @@ -1,5 +1,6 @@ import { DidChangeConfigurationNotification } from "vscode-languageserver"; import { publish } from "../pubsub.js"; +import { clearSchemaDocuments } from "./schema-documents.js"; export let schemaFilePatterns = ["**/*.schema.json", "**/schema.json"]; @@ -23,12 +24,13 @@ export default { connection.onDidChangeConfiguration((change) => { if (hasConfigurationCapability) { documentSettings.clear(); + clearSchemaDocuments(); } else { globalSettings = change.settings.jsonSchemaLanguageServer ?? globalSettings; } schemaFilePatterns = globalSettings.schemaFilePatterns ?? defaultFilePatterns; - publish("workspaceChange", { changes: [] }); + publish("workspaceChanged", { changes: [] }); }); documents.onDidClose(({ document }) => { diff --git a/language-server/src/features/schema-documents.js b/language-server/src/features/schema-documents.js index e439f24..0ee9df9 100644 --- a/language-server/src/features/schema-documents.js +++ b/language-server/src/features/schema-documents.js @@ -30,3 +30,5 @@ export const getSchemaDocument = async (connection, textDocument) => { return schemaDocument; }; + +export const clearSchemaDocuments = () => schemaDocuments.clear(); diff --git a/language-server/src/features/workspace.js b/language-server/src/features/workspace.js index c2db46e..c904fb0 100644 --- a/language-server/src/features/workspace.js +++ b/language-server/src/features/workspace.js @@ -9,7 +9,7 @@ import { TextDocumentSyncKind } from "vscode-languageserver"; import { TextDocument } from "vscode-languageserver-textdocument"; -import { publishAsync } from "../pubsub.js"; +import { publish, publishAsync, subscribe } from "../pubsub.js"; import { getSchemaDocument } from "./schema-documents.js"; import { getDocumentSettings } from "./document-settings.js"; import picomatch from "picomatch"; @@ -60,7 +60,7 @@ export default { // eventType === "rename" means file added or deleted (on most platforms?) // eventType === "change" means file saved // filename is not always available (when is it not available?) - validateWorkspace({ + publish("workspaceChanged", { changes: [ { uri: filename, @@ -70,7 +70,7 @@ export default { }); }; - const validateWorkspace = async (_changes) => { + subscribe("workspaceChanged", async (_message, _changes) => { const reporter = await connection.window.createWorkDoneProgress(); reporter.begin("JSON Schema: Indexing workspace"); @@ -88,7 +88,7 @@ export default { } reporter.done(); - }; + }); const validateSchema = async (textDocument) => { connection.console.log(`Schema Validation: ${textDocument.uri}`); @@ -138,7 +138,7 @@ export default { watchWorkspace(onWorkspaceChange, isMatchedFile); } - validateWorkspace({ changes: [] }); + publish("workspaceChanged", { changes: [] }); }); } @@ -152,7 +152,7 @@ export default { } }); - validateWorkspace({ changes: [] }); + publish("workspaceChanged", { changes: [] }); } };