Include showQuickPick example

This commit is contained in:
Christof Marti
2018-06-28 11:36:23 +02:00
parent 38e4f72b9c
commit fda240cada
2 changed files with 18 additions and 2 deletions

View File

@ -5,6 +5,18 @@
import { window } from 'vscode';
/**
* Shows a pick list using window.showQuickPick().
*/
export async function showQuickPick() {
let i = 0;
const result = await window.showQuickPick(['eins', 'zwei', 'drei'], {
placeHolder: 'eins, zwei or drei',
onDidSelectItem: item => window.showInformationMessage(`Focus ${++i}: ${item}`)
});
window.showInformationMessage(`Got: ${result}`);
}
/**
* Shows an input box using window.showInputBox().
*/
@ -13,7 +25,10 @@ export async function showInputBox() {
value: 'abcdef',
valueSelection: [2, 4],
placeHolder: 'For example: fedcba. But not: 123',
validateInput: text => Promise.resolve(text === '123' ? 'Not 123!' : null)
validateInput: text => {
window.showInformationMessage(`Validating: ${text}`);
return text === '123' ? 'Not 123!' : null;
}
});
window.showInformationMessage(`Got: ${result}`);
}

View File

@ -6,13 +6,14 @@
'use strict';
import { window, commands, ExtensionContext } from 'vscode';
import { showInputBox } from './basicInput';
import { showQuickPick, showInputBox } from './basicInput';
import { multiStepInput } from './multiStepInput';
import { quickOpen } from './quickOpen';
export function activate(context: ExtensionContext) {
context.subscriptions.push(commands.registerCommand('samples.quickInput', async () => {
const options: { [key: string]: (context: ExtensionContext) => Promise<void> } = {
showQuickPick,
showInputBox,
multiStepInput,
quickOpen,