MCPcopy Create free account
hub / github.com/Dart-Code/Dart-Code / showFolderMultiPicker

Function showFolderMultiPicker

src/extension/utils/vscode/projects.ts:106–128  ·  view source on GitHub ↗
(selectableFolderPaths: string[], prePickedFolders: Set<string> | undefined, placeHolder: string)

Source from the content-addressed store, hash-verified

104}
105
106async function showFolderMultiPicker(selectableFolderPaths: string[], prePickedFolders: Set<string> | undefined, placeHolder: string): Promise<string[] | undefined> {
107 // No point asking the user if there's only one.
108 if (selectableFolderPaths.length === 1) {
109 return selectableFolderPaths;
110 }
111
112 const items = selectableFolderPaths.map((selectableFolderPath) => {
113 const workspaceFolder = vs.workspace.getWorkspaceFolder(Uri.file(selectableFolderPath));
114 if (!workspaceFolder)
115 return undefined;
116
117 const workspacePathParent = path.dirname(fsPath(workspaceFolder.uri));
118 return {
119 description: homeRelativePath(workspacePathParent),
120 label: path.relative(workspacePathParent, selectableFolderPath),
121 path: selectableFolderPath,
122 picked: prePickedFolders?.has(selectableFolderPath),
123 } satisfies vs.QuickPickItem & { path: string };
124 }).filter(notUndefined);
125
126 const selectedFolders = await vs.window.showQuickPick(items, { placeHolder, canPickMany: true });
127 return selectedFolders?.map((folder) => folder.path);
128}

Callers 1

getProjectSelectionFunction · 0.85

Calls 3

fsPathFunction · 0.90
homeRelativePathFunction · 0.90
hasMethod · 0.80

Tested by

no test coverage detected