From e011a773967fbf51c4c41f8fd354dc75ae830d0d Mon Sep 17 00:00:00 2001 From: falco Date: Sat, 18 Oct 2025 08:53:24 +0200 Subject: [PATCH] feat: change logic for getting workspace folder to support multi-root workspaces --- src/extension.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 35f2754..e9b91bb 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -313,7 +313,10 @@ function expandPath(pth: string): string { } function getWorkspaceFolder(): string { - let workspaceFolder = vscode.workspace.workspaceFolders?.[0].uri.fsPath; - if (!workspaceFolder) workspaceFolder = os.homedir(); - return workspaceFolder; + const activeDocumentUri = vscode.window.activeTextEditor?.document.uri; + let workspaceFolder: vscode.WorkspaceFolder | undefined; + if (activeDocumentUri) workspaceFolder = vscode.workspace.getWorkspaceFolder(activeDocumentUri); + workspaceFolder ??= vscode.workspace.workspaceFolders?.[0]; + + return workspaceFolder?.uri.fsPath ?? os.homedir(); }