Skip to content

Commit

Permalink
fix diagnostics not being removed when a cell is deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
DetachHead committed Feb 13, 2025
1 parent d3f5d89 commit 824dbc5
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/pyright-internal/src/languageServerBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1288,7 +1288,9 @@ export abstract class LanguageServerBase implements LanguageServerInterface, Dis
const workspaces = await this.getContainingWorkspacesForFile(cellUri);
if (newCell === undefined) {
// a cell was deleted and there's no longer a cell at this index so we need to close it
// Send this close to all the workspaces that might contain this file.
// Send this close to all the workspaces that might contain this file. note that we also
// need to clear diagnostics for the vscode cell uri that no longer exists, which is done
// below using didClose
workspaces.forEach((w) => w.service.setFileClosed(cellUri));
} else {
// this index now has a different cell than it did before (ie. order was changed) so we have to update the already opened cell
Expand All @@ -1308,6 +1310,17 @@ export abstract class LanguageServerBase implements LanguageServerInterface, Dis
}
})
);
if (changeStructure.didClose) {
await Promise.all(
changeStructure.didClose.map((document) =>
// the setFileClosed above will just remove the diagnostics for the underlying cell at the index that
// no longer exists, but we need to also clear diagnostics for the vscode cell uri even if it
// was replaced with a different cell at the same index, bwcause vscode will assign it a
// different uri
this.connection.sendDiagnostics({ diagnostics: [], uri: document.uri })
)
);
}
this._openCells.set(uri.key, newCells);
}
if (params.change.cells?.textContent) {
Expand Down

0 comments on commit 824dbc5

Please sign in to comment.