Skip to content

Commit

Permalink
fix(language-server): avoid project initialized twice
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Aug 24, 2024
1 parent 59f8c03 commit 33aff6a
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions packages/language-server/lib/features/workspaceFolders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,19 @@ export function register(server: LanguageServerState) {
server.onInitialized(() => {
if (server.initializeParams.capabilities.workspace?.workspaceFolders) {
server.connection.workspace.onDidChangeWorkspaceFolders(e => {
for (const folder of e.added) {
folders.set(URI.parse(folder.uri), true);
}
for (const folder of e.removed) {
folders.delete(URI.parse(folder.uri));
}
server.project.reload();
for (const cb of didChangeCallbacks) {
cb(e);
e.added = e.added.filter(folder => !folders.has(URI.parse(folder.uri)));
e.removed = e.removed.filter(folder => folders.has(URI.parse(folder.uri)));
if (e.added.length || e.removed.length) {
for (const folder of e.added) {
folders.set(URI.parse(folder.uri), true);
}
for (const folder of e.removed) {
folders.delete(URI.parse(folder.uri));
}
server.project.reload();
for (const cb of didChangeCallbacks) {
cb(e);
}
}
});
}
Expand Down

0 comments on commit 33aff6a

Please sign in to comment.