src/vs/workbench/contrib/snippets/browser/insertSnippet.ts/InsertSnippetAction/_pickSnippet
class InsertSnippetAction:	private async _pickSnippet(snippetService: ISnippetsService, quickInputService: IQuickInputService, languageId: LanguageId): Promise<Snippet | undefined> {

		interface ISnippetPick extends IQuickPickItem {
			snippet: Snippet;
		}

		const snippets = (await snippetService.getSnippets(languageId, { includeDisabledSnippets: true, includeNoPrefixSnippets: true })).sort(Snippet.compare);

		const makeSnippetPicks = () => {
			const result: QuickPickInput<ISnippetPick>[] = [];
			let prevSnippet: Snippet | undefined;
			for (const snippet of snippets) {
				const pick: ISnippetPick = {
					label: snippet.prefix || snippet.name,
					detail: snippet.description,
					snippet
				};
				if (!prevSnippet || prevSnippet.snippetSource !== snippet.snippetSource) {
					let label = '';
					switch (snippet.snippetSource) {
						case SnippetSource.User:
							label = nls.localize('sep.userSnippet', "User Snippets");
							break;
						case SnippetSource.Extension:
							label = nls.localize('sep.extSnippet', "Extension Snippets");
							break;
						case SnippetSource.Workspace:
							label = nls.localize('sep.workspaceSnippet', "Workspace Snippets");
							break;
					}
					result.push({ type: 'separator', label });
				}

				if (snippet.snippetSource === SnippetSource.Extension) {
					const isEnabled = snippetService.isEnabled(snippet);
					if (isEnabled) {
						pick.buttons = [{
							iconClass: Codicon.eyeClosed.classNames,
							tooltip: nls.localize('disableSnippet', 'Hide from IntelliSense')
						}];
					} else {
						pick.description = nls.localize('isDisabled', "(hidden from IntelliSense)");
						pick.buttons = [{
							iconClass: Codicon.eye.classNames,
							tooltip: nls.localize('enable.snippet', 'Show in IntelliSense')
						}];
					}
				}

				result.push(pick);
				prevSnippet = snippet;
			}
			return result;
		};

		const picker = quickInputService.createQuickPick<ISnippetPick>();
		picker.placeholder = nls.localize('pick.placeholder', "Select a snippet");
		picker.matchOnDetail = true;
		picker.ignoreFocusOut = false;
		picker.onDidTriggerItemButton(ctx => {
			const isEnabled = snippetService.isEnabled(ctx.item.snippet);
			snippetService.updateEnablement(ctx.item.snippet, !isEnabled);
			picker.items = makeSnippetPicks();
		});
		picker.items = makeSnippetPicks();
		picker.show();

		// wait for an item to be picked or the picker to become hidden
		await Promise.race([Event.toPromise(picker.onDidAccept), Event.toPromise(picker.onDidHide)]);
		const result = picker.selectedItems[0]?.snippet;
		picker.dispose();
		return result;
	}