Skip to content

Commit

Permalink
Merge pull request #378 from PowerShell/daviwil/fix-remote-prompt
Browse files Browse the repository at this point in the history
Fix remote prompt ComputerName display
  • Loading branch information
daviwil committed Mar 14, 2017
2 parents aaad6f3 + 09b90d1 commit 14029ee
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 14029ee

Please sign in to comment.