Skip to content

Commit

Permalink
Fix configuration change bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jdesrosiers committed May 20, 2024
1 parent bd66901 commit 35a1a35
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 3 additions & 1 deletion language-server/src/features/document-settings.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { DidChangeConfigurationNotification } from "vscode-languageserver";
import { publish } from "../pubsub.js";
import { clearSchemaDocuments } from "./schema-documents.js";


export const isSchema = RegExp.prototype.test.bind(/(?:\.|\/|^)schema\.json$/);
Expand All @@ -23,11 +24,12 @@ export default {
connection.onDidChangeConfiguration((change) => {
if (hasConfigurationCapability) {
documentSettings.clear();
clearSchemaDocuments();
} else {
globalSettings = change.settings.jsonSchemaLanguageServer ?? globalSettings;
}

publish("workspaceChange", { changes: [] });
publish("workspaceChanged", { changes: [] });
});

documents.onDidClose(({ document }) => {
Expand Down
2 changes: 2 additions & 0 deletions language-server/src/features/schema-documents.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ export const getSchemaDocument = async (connection, textDocument) => {

return schemaDocument;
};

export const clearSchemaDocuments = () => schemaDocuments.clear();
12 changes: 6 additions & 6 deletions language-server/src/features/workspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 { isSchema } from "./document-settings.js";

Expand Down Expand Up @@ -47,7 +47,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,
Expand All @@ -57,7 +57,7 @@ export default {
});
};

const validateWorkspace = async (_changes) => {
subscribe("workspaceChanged", async (_message, _changes) => {
const reporter = await connection.window.createWorkDoneProgress();
reporter.begin("JSON Schema: Indexing workspace");

Expand All @@ -73,7 +73,7 @@ export default {
}

reporter.done();
};
});

const validateSchema = async (textDocument) => {
connection.console.log(`Schema Validation: ${textDocument.uri}`);
Expand Down Expand Up @@ -123,7 +123,7 @@ export default {
watchWorkspace(onWorkspaceChange);
}

validateWorkspace({ changes: [] });
publish("workspaceChanged", { changes: [] });
});
}

Expand All @@ -135,7 +135,7 @@ export default {
}
});

validateWorkspace({ changes: [] });
publish("workspaceChanged", { changes: [] });
}
};

Expand Down

0 comments on commit 35a1a35

Please sign in to comment.