Skip to content

Commit 2e2b31b

Browse files
committed
Fix evaluation of prompt function output to remove unneeded "PS>"
This change fixes an issue in the integrated console where the result of a user's custom prompt function would not be interpreted correctly, causing the default prompt string of "PS>" to be written out when it wasn't needed. The fix is to expect a PSObject result rather than object so that we can evaluate the inner object's type correctly. Resolves PowerShell/vscode-powershell#808.
1 parent 294ce71 commit 2e2b31b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/PowerShellEditorServices/Console/ConsoleService.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ private async Task WritePromptStringToHost()
224224
PSCommand promptCommand = new PSCommand().AddScript("prompt");
225225

226226
string promptString =
227-
(await this.powerShellContext.ExecuteCommand<object>(promptCommand, false, false))
227+
(await this.powerShellContext.ExecuteCommand<PSObject>(promptCommand, false, false))
228+
.Select(pso => pso.BaseObject)
228229
.OfType<string>()
229230
.FirstOrDefault() ?? "PS> ";
230231

0 commit comments

Comments
 (0)