mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-04-27 16:55:44 +08:00
Quick Input Sample
This commit is contained in:
19
quickinput-sample/src/basicInput.ts
Normal file
19
quickinput-sample/src/basicInput.ts
Normal file
@ -0,0 +1,19 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { window } from 'vscode';
|
||||
|
||||
/**
|
||||
* Shows an input box using window.showInputBox().
|
||||
*/
|
||||
export async function showInputBox() {
|
||||
const result = await window.showInputBox({
|
||||
value: 'abcdef',
|
||||
valueSelection: [2, 4],
|
||||
placeHolder: 'For example: fedcba. But not: 123',
|
||||
validateInput: text => Promise.resolve(text === '123' ? 'Not 123!' : null)
|
||||
});
|
||||
window.showInformationMessage(`Got: ${result}`);
|
||||
}
|
||||
Reference in New Issue
Block a user