MCPcopy Create free account
hub / github.com/REditorSupport/vscode-R / pickPackages

Function pickPackages

src/helpViewer/packages.ts:434–460  ·  view source on GitHub ↗
(packages: Package[], placeHolder: string, pickMany: boolean = false)

Source from the content-addressed store, hash-verified

432
433// Let the user pick a package, either from local installation or CRAN
434async function pickPackages(packages: Package[], placeHolder: string, pickMany: boolean = false): Promise<Package[]|undefined> {
435 if(!packages?.length){
436 return undefined;
437 }
438
439 const qpItems: (vscode.QuickPickItem & {package: Package})[] = packages.map(pkg => ({
440 label: pkg.name,
441 detail: pkg.description,
442 package: pkg
443 }));
444
445 const qpOptions: vscode.QuickPickOptions = {
446 matchOnDescription: true,
447 matchOnDetail: true,
448 placeHolder: placeHolder
449 };
450 let ret: Package | Package[] | undefined;
451 if(pickMany){
452 const qp = await vscode.window.showQuickPick(qpItems, {...qpOptions, canPickMany: true});
453 ret = qp?.map(v => v.package);
454 } else{
455 const qp = await vscode.window.showQuickPick(qpItems, qpOptions);
456 ret = (qp ? [qp.package] : undefined);
457 }
458
459 return ret;
460}
461
462// Used to summarize index-entries that point to the same help file
463function summarizeTopics(topics: Topic[]): Topic[] {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected