Skip to content

Instantly share code, notes, and snippets.

@ecool
Created January 8, 2021 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ecool/a6b12280c61c83561ed0e421f685882f to your computer and use it in GitHub Desktop.
Save ecool/a6b12280c61c83561ed0e421f685882f to your computer and use it in GitHub Desktop.
QuickPick Multi-Select Custom Input Issue Example
export async function showMultiSelectInputBox(): Promise<string[]> {
const items = ["testing", "boop", "77708"];
const mappedItems = items.map((item) => ({ label: item }));
return new Promise((resolve, _) => {
const quickPick = window.createQuickPick();
quickPick.placeholder = "Select/Insert a selection.";
quickPick.items = mappedItems;
// when this is true, quickPick.activeItems is an empty list [] onDidAccept
// quickPick.canSelectMany = false;
quickPick.canSelectMany = true;
quickPick.onDidAccept(_ => {
console.log(quickPick);
// resolves to empty list
resolve(quickPick.activeItems.map((item) => item.label));
quickPick.hide();
});
// Allows for custom item to be selected
// quickPick.onDidChangeValue(_ => {
// if (quickPick.value === "") {
// quickPick.items = mappedItems;
// } else {
// // include currently typed option
// quickPick.items = [{ label: quickPick.value }, ...mappedItems];
// }
// });
quickPick.onDidHide(_ => quickPick.dispose());
quickPick.show();
});
}
@ecool
Copy link
Author

ecool commented Jan 8, 2021

const result = await showMultiSelectInputBox();
console.log(result);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment