(logger: Logger, placeHolder: string)
| 55 | } |
| 56 | |
| 57 | export async function getProjectSelection(logger: Logger, placeHolder: string): Promise<string[] | undefined> { |
| 58 | // Attempt to find a project based on the supplied folder of active file so we can pre-selected it. |
| 59 | const activeEditor = getActiveRealFileEditor(); |
| 60 | const activeUri = activeEditor ? activeEditor.document.uri : undefined; |
| 61 | const activeFilePath = activeUri?.scheme === "file" ? fsPath(activeUri) : undefined; |
| 62 | const activeProjectFolder = activeFilePath ? locateBestProjectRoot(activeFilePath) : undefined; |
| 63 | |
| 64 | // Find all possible projects. |
| 65 | const selectableProjectFolders = (await getAllProjectFolders(logger, getExcludedFolders, { requirePubspec: true, sort: true, searchDepth: config.projectSearchDepth })); |
| 66 | if (!selectableProjectFolders?.length) { |
| 67 | void vs.window.showWarningMessage(`No project roots were found. Does your project have a pubspec.yaml file?`); |
| 68 | return undefined; |
| 69 | } |
| 70 | |
| 71 | if (selectableProjectFolders.length === 1) { |
| 72 | return selectableProjectFolders; |
| 73 | } |
| 74 | |
| 75 | const prePickedFolders = activeProjectFolder ? new Set([activeProjectFolder]) : undefined; |
| 76 | return showFolderMultiPicker(selectableProjectFolders, prePickedFolders, placeHolder); |
| 77 | } |
| 78 | |
| 79 | async function showPackagePicker(folders: PubWorkspaceOrPackageFolderInfo[], placeHolder: string): Promise<string | undefined> { |
| 80 | // No point asking the user if there's only one. |
no test coverage detected