(folders: PubWorkspaceOrPackageFolderInfo[], placeHolder: string)
| 77 | } |
| 78 | |
| 79 | async function showPackagePicker(folders: PubWorkspaceOrPackageFolderInfo[], placeHolder: string): Promise<string | undefined> { |
| 80 | // No point asking the user if there's only one. |
| 81 | if (folders.length === 1) { |
| 82 | return folders[0]?.path; |
| 83 | } |
| 84 | |
| 85 | const items = folders.map((folderInfo) => { |
| 86 | const folderPath = folderInfo.path; |
| 87 | const workspaceFolder = vs.workspace.getWorkspaceFolder(Uri.file(folderPath)); |
| 88 | const workspacePathParent = workspaceFolder |
| 89 | ? path.dirname(fsPath(workspaceFolder.uri)) |
| 90 | : path.dirname(folderPath); |
| 91 | const detail = folderInfo.workspacePackageCount |
| 92 | ? `Pub Workspace, ${folderInfo.workspacePackageCount} package${folderInfo.workspacePackageCount === 1 ? "" : "s"}` |
| 93 | : undefined; |
| 94 | return { |
| 95 | description: homeRelativePath(workspacePathParent), |
| 96 | label: path.relative(workspacePathParent, folderPath), |
| 97 | detail, |
| 98 | path: folderPath, |
| 99 | } satisfies vs.QuickPickItem & { path: string }; |
| 100 | }).filter(notUndefined); |
| 101 | |
| 102 | const selectedFolder = await vs.window.showQuickPick(items, { placeHolder }); |
| 103 | return selectedFolder?.path; |
| 104 | } |
| 105 | |
| 106 | async function showFolderMultiPicker(selectableFolderPaths: string[], prePickedFolders: Set<string> | undefined, placeHolder: string): Promise<string[] | undefined> { |
| 107 | // No point asking the user if there's only one. |
no test coverage detected