Skip to content

Commit 686e062

Browse files
authored
Improved Handling for Problems in Closed/Deleted Files
1 parent eb3717b commit 686e062

File tree

1 file changed

+14
-4
lines changed
  • src/features/providers/linter

1 file changed

+14
-4
lines changed

src/features/providers/linter/lint.ts

+14-4
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,21 @@ export default class LintingProvider {
3131
vscode.workspace.onDidChangeConfiguration(this.loadConfiguration, this, subscriptions);
3232
vscode.workspace.onDidOpenTextDocument(this.triggerLint, this, subscriptions);
3333
vscode.workspace.onDidCloseTextDocument(
34-
(textDocument) => {
35-
if (!Configuration.lintEntireProject()) {
36-
this.diagnosticCollection.delete(textDocument.uri);
34+
async (textDocument) => {
35+
const { uri } = textDocument;
36+
let doesDocumentExist = true;
37+
38+
try {
39+
await vscode.workspace.fs.stat(uri);
40+
} catch {
41+
doesDocumentExist = false;
42+
}
43+
44+
if (!Configuration.lintEntireProject() || !vscode.workspace.getWorkspaceFolder(uri) || !doesDocumentExist) {
45+
this.diagnosticCollection.delete(uri);
3746
}
38-
delete this.delayers[textDocument.uri.toString()];
47+
48+
delete this.delayers[uri.toString()];
3949
},
4050
null,
4151
subscriptions

0 commit comments

Comments
 (0)