Skip to content

Commit

Permalink
Fix remote prompt ComputerName display
Browse files Browse the repository at this point in the history
This change fixes the ComputerName prefix for prompts shown in remote
sessions.  Recent changes caused it to be lost.
  • Loading branch information
daviwil committed Mar 14, 2017
1 parent aaad6f3 commit 09b90d1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
21 changes: 18 additions & 3 deletions src/PowerShellEditorServices/Console/ConsoleService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

namespace Microsoft.PowerShell.EditorServices.Console
{
using Microsoft.PowerShell.EditorServices.Session;
using System;
using System.Globalization;
using System.Management.Automation;
using System.Security;

Expand Down Expand Up @@ -264,10 +266,23 @@ public async Task<SecureString> ReadSecureLine(CancellationToken cancellationTok

private void WritePromptStringToHost()
{
string promptString = this.powerShellContext.PromptString;

// Update the stored prompt string if the session is remote
if (this.powerShellContext.CurrentRunspace.Location == RunspaceLocation.Remote)
{
promptString =
string.Format(
CultureInfo.InvariantCulture,
"[{0}]: {1}",
this.powerShellContext.CurrentRunspace.Runspace.ConnectionInfo != null
? this.powerShellContext.CurrentRunspace.Runspace.ConnectionInfo.ComputerName
: this.powerShellContext.CurrentRunspace.SessionDetails.ComputerName,
promptString);
}

// Write the prompt string
this.WriteOutput(
this.powerShellContext.PromptString,
false);
this.WriteOutput(promptString, false);
}

private void WriteDebuggerBanner(DebuggerStopEventArgs eventArgs)
Expand Down
11 changes: 0 additions & 11 deletions src/PowerShellEditorServices/Session/PowerShellContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1367,17 +1367,6 @@ private SessionDetails GetSessionDetailsInRunspace(Runspace runspace)
}
});

if (this.CurrentRunspace != null &&
this.CurrentRunspace.Location == RunspaceLocation.Remote)
{
sessionDetails.PromptString =
string.Format(
CultureInfo.InvariantCulture,
"[{0}]: {1}",
runspace.ConnectionInfo.ComputerName,
sessionDetails.PromptString);
}

return sessionDetails;
}

Expand Down

0 comments on commit 09b90d1

Please sign in to comment.