Skip to content

Commit 9836774

Browse files
authored
Focus root folder for packages w/ sub-packages (#1766)
When loading a workspace we check if there is only one folder added, and if so we focus it. Focusing a folder then kicks off things like package resolution and test discovery. However, if a package contained sub-packages we treated this as a multi-root workspace and would not focus any. In this situation we actually want to focus the root folder. If we're in a multi-root workspace then we maintain the old behaviour as its unclear what folder should be focused. Issue: #1760
1 parent c198a25 commit 9836774

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/WorkspaceContext.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,15 +336,18 @@ export class WorkspaceContext implements vscode.Disposable {
336336
await this.addWorkspaceFolder(folder);
337337
}
338338
}
339+
339340
// If we don't have a current selected folder Start up language server by firing focus event
340-
// on either null folder or the first folder if there is only one
341+
// on the first root folder found in the workspace if there is only one.
341342
if (this.currentFolder === undefined) {
342-
if (this.folders.length === 1) {
343-
await this.focusFolder(this.folders[0]);
343+
const rootFolders = this.folders.filter(folder => folder.isRootFolder);
344+
if (rootFolders.length === 1) {
345+
await this.focusFolder(rootFolders[0]);
344346
} else {
345347
await this.focusFolder(null);
346348
}
347349
}
350+
348351
await this.initialisationComplete();
349352
}
350353

0 commit comments

Comments
 (0)