From bea0153f3462723bd4a8edbf21f55634d5ed08a8 Mon Sep 17 00:00:00 2001 From: Brett Saviano Date: Thu, 3 Apr 2025 17:08:19 -0400 Subject: [PATCH] Fix compile loop when one workspace folderis the child of another --- src/utils/documentIndex.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/utils/documentIndex.ts b/src/utils/documentIndex.ts index 59158d62..8cdcf476 100644 --- a/src/utils/documentIndex.ts +++ b/src/utils/documentIndex.ts @@ -177,10 +177,20 @@ export async function indexWorkspaceFolder(wsFolder: vscode.WorkspaceFolder): Pr // part of the workspace folder, like "git" files return; } + if (vscode.workspace.getWorkspaceFolder(uri)?.uri.toString() != wsFolder.uri.toString()) { + // This file is not in this workspace folder. This can occur if there + // are two workspace folders open where one is a subfolder of the other + // and the file being changed is in the subfolder. This event will fire + // for both watchers, but VS Code will correctly report that the file + // is in the subfolder workspace folder, so the parent watcher can + // safely ignore the event. + return; + } const uriString = uri.toString(); if (openCustomEditors.includes(uriString)) { // This class is open in a graphical editor, so its name will not change // and any updates to the class will be handled by that editor + touchedByVSCode.delete(uriString); return; } if (exportedUris.has(uriString)) { @@ -188,6 +198,7 @@ export async function indexWorkspaceFolder(wsFolder: vscode.WorkspaceFolder): Pr // export, so don't re-sync the file with the server. // The index has already been updated. exportedUris.delete(uriString); + touchedByVSCode.delete(uriString); return; } const api = new AtelierAPI(uri); @@ -225,6 +236,15 @@ export async function indexWorkspaceFolder(wsFolder: vscode.WorkspaceFolder): Pr // part of the workspace folder, like "git" files return; } + if (vscode.workspace.getWorkspaceFolder(uri)?.uri.toString() != wsFolder.uri.toString()) { + // This file is not in this workspace folder. This can occur if there + // are two workspace folders open where one is a subfolder of the other + // and the file being changed is in the subfolder. This event will fire + // for both watchers, but VS Code will correctly report that the file + // is in the subfolder workspace folder, so the parent watcher can + // safely ignore the event. + return; + } const uriString = uri.toString(); const api = new AtelierAPI(uri); const syncLocalChanges: string = vscode.workspace