Skip to content

Commit 65800eb

Browse files
committed
(maint) Move PDK Commands to showInputBox
This commit moves all of the PDK Commands to use an async showInputBox instead of a thenable. It also simplifies the showInputBox to use placeHolder text instead of a QuickPickOptions.
1 parent f4549b9 commit 65800eb

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

src/feature/PDKFeature.ts

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
import * as fs from 'fs';
24
import * as path from 'path';
35
import * as vscode from 'vscode';
@@ -47,25 +49,21 @@ export class PDKFeature implements IFeature {
4749
{ id: 'extension.pdkNewDefinedType', request: 'pdk new defined_type', type: 'Puppet defined_type' },
4850
].forEach((command) => {
4951
context.subscriptions.push(
50-
vscode.commands.registerCommand(command.id, () => {
51-
const nameOpts: vscode.QuickPickOptions = {
52-
placeHolder: `Enter a name for the new ${command.type}`,
53-
matchOnDescription: true,
54-
matchOnDetail: true,
55-
};
56-
57-
vscode.window.showInputBox(nameOpts).then((name) => {
58-
if (name === undefined) {
59-
vscode.window.showWarningMessage(`No ${command.type} value specifed. Exiting.`);
60-
return;
61-
}
62-
const request = `${command.request} ${name}`;
63-
this.terminal.sendText(request);
64-
this.terminal.show();
65-
if (reporter) {
66-
reporter.sendTelemetryEvent(command.id);
67-
}
52+
vscode.commands.registerCommand(command.id, async () => {
53+
const name = await vscode.window.showInputBox({
54+
prompt: `Enter a name for the new ${command.type}`,
6855
});
56+
if (name === undefined) {
57+
vscode.window.showWarningMessage('No module name specifed. Exiting.');
58+
return;
59+
}
60+
61+
const request = `${command.request} ${name}`;
62+
this.terminal.sendText(request);
63+
this.terminal.show();
64+
if (reporter) {
65+
reporter.sendTelemetryEvent(command.id);
66+
}
6967
}),
7068
);
7169
logger.debug(`Registered ${command.id} command`);

0 commit comments

Comments
 (0)