Skip to content

Commit 4f2c62a

Browse files
Fix diagnostics not triggered for files open before extension activation (#356)
* Initial plan * fix: process already-open documents on extension activation for diagnostics Co-authored-by: garrytrinder <11563347+garrytrinder@users.noreply.github.com> * refactor: include document URI in error log for already-open document processing Co-authored-by: garrytrinder <11563347+garrytrinder@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: garrytrinder <11563347+garrytrinder@users.noreply.github.com>
1 parent f728a62 commit 4f2c62a

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2626

2727
- Logging: Fixed log flooding from repeated running state checks by only logging on state changes
2828
- Logging: Fixed log feedback loop caused by Output Channel document events triggering diagnostics
29-
29+
- Diagnostics: Run diagnostics for Dev Proxy files already open before extension activation
3030
- Diagnostics: Language model diagnostic now correctly targets plugins that can use a local language model (OpenAIMockResponsePlugin, OpenApiSpecGeneratorPlugin, TypeSpecGeneratorPlugin) and shows as an informational hint instead of a warning
3131

3232
## [1.12.0] - 2026-01-29

src/documents.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,26 @@ export const registerDocumentListeners = (context: vscode.ExtensionContext, coll
7676
});
7777
})
7878
);
79+
80+
// Process already-open documents that were opened before the extension activated
81+
for (const document of vscode.workspace.textDocuments) {
82+
if (document.uri.scheme !== 'file') {
83+
continue;
84+
}
85+
try {
86+
if (isConfigFile(document)) {
87+
updateConfigFileDiagnostics(context, document, collection);
88+
} else if (isProxyFile(document)) {
89+
updateFileDiagnostics(context, document, collection);
90+
}
91+
} catch (error) {
92+
console.error('Error processing already-open document:', document.uri.fsPath, error);
93+
}
94+
}
95+
96+
// Set context for the active editor if it contains a config file
97+
const activeEditor = vscode.window.activeTextEditor;
98+
if (activeEditor && activeEditor.document.uri.scheme === 'file') {
99+
vscode.commands.executeCommand('setContext', 'isDevProxyConfigFile', isConfigFile(activeEditor.document));
100+
}
79101
};

0 commit comments

Comments
 (0)