Skip to content

Commit 3be8e91

Browse files
committed
vscode-extension: fix language server crash when first workspace folder does not exist on the file system
Instead, loops through the workspace folders until it finds one that exists and is a directory
1 parent 079829d commit 3be8e91

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

vscode-extension/src/main/ts/extension.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,11 @@ function startClient() {
694694
// args.unshift("-Xlog:all=warning:stderr")
695695
let primaryWorkspaceFolder: vscode.WorkspaceFolder | undefined;
696696
if (vscode.workspace.workspaceFolders !== undefined) {
697-
primaryWorkspaceFolder = vscode.workspace.workspaceFolders[0];
697+
primaryWorkspaceFolder = vscode.workspace.workspaceFolders.find(
698+
(folder) =>
699+
fs.existsSync(folder.uri.fsPath) &&
700+
fs.statSync(folder.uri.fsPath).isDirectory(),
701+
);
698702
}
699703
//uncomment to allow a debugger to attach to the language server
700704
//args.unshift("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005,quiet=y");

0 commit comments

Comments
 (0)