Skip to content

Change SpecifyScriptArgs command to only return string - not string[] #1317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 6 additions & 22 deletions src/features/DebugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,21 +178,10 @@ export class SpecifyScriptArgsFeature implements IFeature {
private command: vscode.Disposable;
private languageClient: LanguageClient;
private context: vscode.ExtensionContext;
private emptyInputBoxBugFixed: boolean;

constructor(context: vscode.ExtensionContext) {
this.context = context;

const vscodeVersionArray = vscode.version.split(".");
const editorVersion = {
major: Number(vscodeVersionArray[0]),
minor: Number(vscodeVersionArray[1]),
};

this.emptyInputBoxBugFixed =
((editorVersion.major > 1) ||
((editorVersion.major === 1) && (editorVersion.minor > 12)));

this.command =
vscode.commands.registerCommand("PowerShell.SpecifyScriptArgs", () => {
return this.specifyScriptArguments();
Expand All @@ -207,29 +196,24 @@ export class SpecifyScriptArgsFeature implements IFeature {
this.command.dispose();
}

private specifyScriptArguments(): Thenable<string[] | string> {
private specifyScriptArguments(): Thenable<string> {
const powerShellDbgScriptArgsKey = "powerShellDebugScriptArgs";

const options: vscode.InputBoxOptions = {
ignoreFocusOut: true,
placeHolder: "Enter script arguments or leave empty to pass no args",
};

if (this.emptyInputBoxBugFixed) {
const prevArgs = this.context.workspaceState.get(powerShellDbgScriptArgsKey, "");
if (prevArgs.length > 0) {
options.value = prevArgs;
}
const prevArgs = this.context.workspaceState.get(powerShellDbgScriptArgsKey, "");
if (prevArgs.length > 0) {
options.value = prevArgs;
}

return vscode.window.showInputBox(options).then((text) => {
// When user cancel's the input box (by pressing Esc), the text value is undefined.
// Let's not blow away the previous settting.
if (text !== undefined) {
if (this.emptyInputBoxBugFixed) {
this.context.workspaceState.update(powerShellDbgScriptArgsKey, text);
}

return new Array(text);
this.context.workspaceState.update(powerShellDbgScriptArgsKey, text);
}

return text;
Expand Down