mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-04-27 16:55:44 +08:00
Include showQuickPick example
This commit is contained in:
@ -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}`);
|
||||
}
|
||||
|
||||
@ -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,
|
||||
|
||||
Reference in New Issue
Block a user