diff --git a/src/provider/linter.ts b/src/provider/linter.ts index 7afab2d..42b4a4a 100644 --- a/src/provider/linter.ts +++ b/src/provider/linter.ts @@ -109,6 +109,12 @@ export async function registerLinter(context: vscode.ExtensionContext) { } }), ); + context.subscriptions.push( + vscode.workspace.onDidCloseTextDocument((document) => { + // 文件关闭(删除)后清空诊断 + collection.clear(); + }), + ); context.subscriptions.push( vscode.workspace.onDidChangeTextDocument((editor) => { if (editor) {