Skip to content

Commit c208181

Browse files
committed
Add vscode version check for save state.
This is for the prompt for script args UI. If on >= 1.13 then save state. If less than that do not save state because there is a bug in VSCode that will make it impossible to specify no args after specify some args -even across different sessions.
1 parent bbd5d7f commit c208181

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

src/features/DebugSession.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,21 @@ export class SpecifyScriptArgsFeature implements IFeature {
111111
private command: vscode.Disposable;
112112
private languageClient: LanguageClient;
113113
private context: vscode.ExtensionContext;
114+
private emptyInputBoxBugFixed: boolean;
114115

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

119+
let vscodeVersionArray = vscode.version.split('.');
120+
let editorVersion = {
121+
major: Number(vscodeVersionArray[0]),
122+
minor: Number(vscodeVersionArray[1]),
123+
}
124+
125+
this.emptyInputBoxBugFixed =
126+
((editorVersion.major > 1) ||
127+
((editorVersion.major == 1) && (editorVersion.minor > 12)));
128+
118129
this.command =
119130
vscode.commands.registerCommand('PowerShell.SpecifyScriptArgs', () => {
120131
return this.specifyScriptArguments();
@@ -137,15 +148,19 @@ export class SpecifyScriptArgsFeature implements IFeature {
137148
placeHolder: "Enter script arguments or leave empty to pass no args"
138149
}
139150

140-
let prevArgs = this.context.globalState.get(powerShellDbgScriptArgsKey, '');
141-
if (prevArgs.length > 0) {
142-
options.value = prevArgs;
151+
if (this.emptyInputBoxBugFixed) {
152+
let prevArgs = this.context.globalState.get(powerShellDbgScriptArgsKey, '');
153+
if (prevArgs.length > 0) {
154+
options.value = prevArgs;
155+
}
143156
}
144157

145158
return vscode.window.showInputBox(options).then(text => {
146159
// When user cancel's the input box (by pressing Esc), the text value is undefined.
147160
if (text !== undefined) {
148-
this.context.globalState.update(powerShellDbgScriptArgsKey, text);
161+
if (this.emptyInputBoxBugFixed) {
162+
this.context.globalState.update(powerShellDbgScriptArgsKey, text);
163+
}
149164
return new Array(text);
150165
}
151166

0 commit comments

Comments
 (0)