Skip to content

Commit e700c17

Browse files
committed
Remember script args from prev session.
This currently has an issue where you can't clear the previous args to send no args. This is has been addressed in VSCode for May 2017 drop - microsoft/vscode#25712 (comment)
1 parent 62bd18a commit e700c17

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/features/DebugSession.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,10 @@ export class SpecifyScriptArgsFeature implements IFeature {
110110

111111
private command: vscode.Disposable;
112112
private languageClient: LanguageClient;
113+
private context: vscode.ExtensionContext;
113114

114-
constructor() {
115+
constructor(context: vscode.ExtensionContext) {
116+
this.context = context;
115117

116118
this.command =
117119
vscode.commands.registerCommand('PowerShell.SpecifyScriptArgs', () => {
@@ -128,13 +130,25 @@ export class SpecifyScriptArgsFeature implements IFeature {
128130
}
129131

130132
private specifyScriptArguments(): Thenable<string[]> {
133+
const powerShellDbgScriptArgsKey = 'powerShellDebugScriptArgs';
134+
131135
let options: vscode.InputBoxOptions = {
132136
ignoreFocusOut: true,
133-
placeHolder: "Enter script arguments"
137+
placeHolder: "Enter script arguments or leave empty to pass no args"
138+
}
139+
140+
let prevArgs = this.context.globalState.get(powerShellDbgScriptArgsKey, '');
141+
if (prevArgs.length > 0) {
142+
options.value = prevArgs;
134143
}
135144

136145
return vscode.window.showInputBox(options).then(text => {
137-
return text !== undefined ? new Array(text) : text;
146+
if (text !== undefined) {
147+
this.context.globalState.update(powerShellDbgScriptArgsKey, text);
148+
return new Array(text);
149+
}
150+
151+
return text;
138152
});
139153
}
140154
}

src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export function activate(context: vscode.ExtensionContext): void {
115115
new RemoteFilesFeature(),
116116
new DebugSessionFeature(),
117117
new PickPSHostProcessFeature(),
118-
new SpecifyScriptArgsFeature()
118+
new SpecifyScriptArgsFeature(context)
119119
];
120120

121121
sessionManager =

0 commit comments

Comments
 (0)