From 2e2b31b725d8687a2fc905767af3832609deff58 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Wed, 31 May 2017 15:44:25 -0700 Subject: [PATCH] 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. --- src/PowerShellEditorServices/Console/ConsoleService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/PowerShellEditorServices/Console/ConsoleService.cs b/src/PowerShellEditorServices/Console/ConsoleService.cs index 8d1011139..06f5df236 100644 --- a/src/PowerShellEditorServices/Console/ConsoleService.cs +++ b/src/PowerShellEditorServices/Console/ConsoleService.cs @@ -224,7 +224,8 @@ private async Task WritePromptStringToHost() PSCommand promptCommand = new PSCommand().AddScript("prompt"); string promptString = - (await this.powerShellContext.ExecuteCommand(promptCommand, false, false)) + (await this.powerShellContext.ExecuteCommand(promptCommand, false, false)) + .Select(pso => pso.BaseObject) .OfType() .FirstOrDefault() ?? "PS> ";