Skip to content

Commit 73b1053

Browse files
committed
docs: add VS Code issue references for textDocuments lazy loading
Document why we use openTextDocument() instead of textDocuments.find() in batch save operations. The textDocuments array has lazy loading behavior and may not contain programmatically opened documents. References: - microsoft/vscode#33546 - microsoft/vscode#38665
1 parent c53ef0b commit 73b1053

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/commands/batch-organizer.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,11 @@ export class BatchOrganizer {
348348

349349
// CRITICAL: Save all modified documents to disk!
350350
// workspace.applyEdit() only modifies in-memory documents, doesn't save!
351-
// NOTE: We must explicitly open each document because files that weren't already
352-
// open may not appear in workspace.textDocuments (race condition fix).
351+
//
352+
// NOTE: We must explicitly open each document because workspace.textDocuments
353+
// has lazy loading behavior - it only contains documents that have been "activated".
354+
// See: https://github.com/microsoft/vscode/issues/33546
355+
// See: https://github.com/microsoft/vscode/issues/38665
353356
const saveFailed: string[] = [];
354357
let savedCount = 0;
355358
for (const [fileUri] of workspaceEdit.entries()) {

0 commit comments

Comments
 (0)