Skip to content

Commit

Permalink
fix(server): parseDocument on each modificiation
Browse files Browse the repository at this point in the history
  • Loading branch information
EmileRolley committed Jun 4, 2024
1 parent 435fd28 commit 3ae4b22
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 5 additions & 0 deletions server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { semanticTokensFullProvider } from "./semanticTokens";
import Engine from "publicodes";
import { fileURLToPath } from "node:url";
import { deleteFileFromCtx } from "./helpers";
import { parseDocument } from "./parseRules";

let ctx: LSContext = {
// Create a connection for the server, using Node's IPC as a transport.
Expand Down Expand Up @@ -92,6 +93,10 @@ ctx.documents.onDidSave((e) => {
validate(ctx, e.document);
});

ctx.documents.onDidChangeContent((e) => {
parseDocument(ctx, fileURLToPath(e.document.uri), e.document);
});

ctx.connection.workspace.onDidDeleteFiles((e: DeleteFilesParams) => {
e.files.forEach(({ uri }) => {
ctx.connection.console.log(`[onDidDeleteFiles] ${uri}`);
Expand Down
2 changes: 0 additions & 2 deletions server/src/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ export default async function validate(
ctx.diagnostics = new Map();

if (document) {
// Parse the document only if it has changed (not needed when a file is
// deleted for example)
const docFilePath = fileURLToPath(document.uri);
parseDocument(ctx, docFilePath, document);
}
Expand Down

0 comments on commit 3ae4b22

Please sign in to comment.