MCPcopy Create free account
hub / github.com/Borvik/vscode-postgres / showQuickPick

Method showQuickPick

src/common/multiStepInput.ts:166–224  ·  view source on GitHub ↗
({title, step, totalSteps, items, activeItem, placeholder, ignoreFocusOut, matchOnDescription, matchOnDetail, canPickMany, convert, buttons, shouldResume}: P)

Source from the content-addressed store, hash-verified

164 }
165
166 async showQuickPick<T extends QuickPickItem, P extends QuickPickParameters<T>>({title, step, totalSteps, items, activeItem, placeholder, ignoreFocusOut, matchOnDescription, matchOnDetail, canPickMany, convert, buttons, shouldResume}: P) {
167 const disposables: Disposable[] = [];
168 try {
169 return await new Promise<any>((resolve, reject) => {
170 const input = window.createQuickPick<T>();
171 input.title = title;
172 input.step = step;
173 input.totalSteps = totalSteps;
174 input.placeholder = placeholder;
175 input.ignoreFocusOut = !!ignoreFocusOut;
176 input.matchOnDescription = !!matchOnDescription;
177 input.matchOnDetail = !!matchOnDetail;
178 input.canSelectMany = !!canPickMany;
179 input.items = items;
180 if (activeItem) {
181 input.activeItems = [activeItem];
182 }
183 input.buttons = [
184 ...(this.steps.length > 1 ? [QuickInputButtons.Back] : []),
185 ...(buttons || [])
186 ];
187 disposables.push(
188 input.onDidTriggerButton(item => {
189 if (item === QuickInputButtons.Back) {
190 reject(InputFlowAction.Back);
191 } else {
192 resolve(<any>item);
193 }
194 }),
195 input.onDidAccept(async () => {
196 if (!convert) convert = async (value: T) => value;
197 let convertedItems: any[] = await Promise.all(input.activeItems.map(v => convert(v)));
198 if (canPickMany) {
199 resolve(convertedItems);
200 } else {
201 resolve(convertedItems[0]);
202 }
203 }),
204 input.onDidHide(async () => {
205 try {
206 reject(shouldResume && await shouldResume() ? InputFlowAction.Resume : InputFlowAction.Cancel);
207 }
208 catch(errorInShouldResume) {
209 reject(errorInShouldResume);
210 }
211 })
212 );
213
214 if (this.current) {
215 this.current.dispose();
216 }
217 this.current = input;
218 setTimeout(() => input.show(), 5);
219 });
220 }
221 finally {
222 disposables.forEach(d => d.dispose());
223 }

Callers 8

runMethod · 0.80
setSSLMethod · 0.80
setDatabaseMethod · 0.80
runMethod · 0.80
runMethod · 0.80
runMethod · 0.80
runMethod · 0.80
runMethod · 0.80

Calls 2

showMethod · 0.80
disposeMethod · 0.45

Tested by

no test coverage detected