Skip to content

Commit ec2c814

Browse files
committed
Fix issues when invoking default values of input and choice fields
This change fixes a couple of issues that appear when the user presses Enter to accept default values of input or choice prompts. This issue appeared when running through the default New Project template that is shipped with Plaster. Fixes PowerShell/vscode-powershell#504.
1 parent c242a1f commit ec2c814

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

Diff for: src/PowerShellEditorServices/Console/ChoicePromptHandler.cs

+8-1
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,15 @@ private async Task<int[]> StartPromptLoop(
199199
break;
200200
}
201201

202-
// If the handler returns null it means we should prompt again
203202
choiceIndexes = this.HandleResponse(responseString);
203+
204+
// Return the default choice values if no choices were entered
205+
if (choiceIndexes == null && string.IsNullOrEmpty(responseString))
206+
{
207+
choiceIndexes = this.DefaultChoices;
208+
}
209+
210+
// If the user provided no choices, we should prompt again
204211
if (choiceIndexes != null)
205212
{
206213
break;

Diff for: src/PowerShellEditorServices/Session/SessionPSHostUserInterface.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ public override Dictionary<string, PSObject> Prompt(
119119
{
120120
psObjectDict.Add(
121121
keyValuePair.Key,
122-
PSObject.AsPSObject(keyValuePair.Value));
122+
keyValuePair.Value != null
123+
? PSObject.AsPSObject(keyValuePair.Value)
124+
: null);
123125
}
124126
}
125127

0 commit comments

Comments
 (0)