File tree Expand file tree Collapse file tree 2 files changed +18
-14
lines changed
src/PowerShellEditorServices Expand file tree Collapse file tree 2 files changed +18
-14
lines changed Original file line number Diff line number Diff line change 1010
1111namespace Microsoft . PowerShell . EditorServices . Console
1212{
13+ using Microsoft . PowerShell . EditorServices . Session ;
1314 using System ;
15+ using System . Globalization ;
1416 using System . Management . Automation ;
1517 using System . Security ;
1618
@@ -264,10 +266,23 @@ public async Task<SecureString> ReadSecureLine(CancellationToken cancellationTok
264266
265267 private void WritePromptStringToHost ( )
266268 {
269+ string promptString = this . powerShellContext . PromptString ;
270+
271+ // Update the stored prompt string if the session is remote
272+ if ( this . powerShellContext . CurrentRunspace . Location == RunspaceLocation . Remote )
273+ {
274+ promptString =
275+ string . Format (
276+ CultureInfo . InvariantCulture ,
277+ "[{0}]: {1}" ,
278+ this . powerShellContext . CurrentRunspace . Runspace . ConnectionInfo != null
279+ ? this . powerShellContext . CurrentRunspace . Runspace . ConnectionInfo . ComputerName
280+ : this . powerShellContext . CurrentRunspace . SessionDetails . ComputerName ,
281+ promptString ) ;
282+ }
283+
267284 // Write the prompt string
268- this . WriteOutput (
269- this . powerShellContext . PromptString ,
270- false ) ;
285+ this . WriteOutput ( promptString , false ) ;
271286 }
272287
273288 private void WriteDebuggerBanner ( DebuggerStopEventArgs eventArgs )
Original file line number Diff line number Diff line change @@ -1367,17 +1367,6 @@ private SessionDetails GetSessionDetailsInRunspace(Runspace runspace)
13671367 }
13681368 } ) ;
13691369
1370- if ( this . CurrentRunspace != null &&
1371- this . CurrentRunspace . Location == RunspaceLocation . Remote )
1372- {
1373- sessionDetails . PromptString =
1374- string . Format (
1375- CultureInfo . InvariantCulture ,
1376- "[{0}]: {1}" ,
1377- runspace . ConnectionInfo . ComputerName ,
1378- sessionDetails . PromptString ) ;
1379- }
1380-
13811370 return sessionDetails ;
13821371 }
13831372
You can’t perform that action at this time.
0 commit comments