File tree 3 files changed +20
-18
lines changed
src/PowerShellEditorServices
3 files changed +20
-18
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ namespace Microsoft.PowerShell.EditorServices.Console
13
13
using Microsoft . PowerShell . EditorServices . Session ;
14
14
using System ;
15
15
using System . Globalization ;
16
+ using System . Linq ;
16
17
using System . Management . Automation ;
17
18
using System . Security ;
18
19
@@ -218,9 +219,24 @@ public async Task<SecureString> ReadSecureLine(CancellationToken cancellationTok
218
219
219
220
#region Private Methods
220
221
221
- private void WritePromptStringToHost ( )
222
+ private async Task WritePromptStringToHost ( )
222
223
{
223
- string promptString = this . powerShellContext . PromptString ;
224
+ PSCommand promptCommand = new PSCommand ( ) . AddScript ( "prompt" ) ;
225
+
226
+ string promptString =
227
+ ( await this . powerShellContext . ExecuteCommand < object > ( promptCommand , false , false ) )
228
+ . OfType < string > ( )
229
+ . FirstOrDefault ( ) ?? "PS> " ;
230
+
231
+ // Add the [DBG] prefix if we're stopped in the debugger
232
+ if ( this . powerShellContext . IsDebuggerStopped )
233
+ {
234
+ promptString =
235
+ string . Format (
236
+ CultureInfo . InvariantCulture ,
237
+ "[DBG]: {0}" ,
238
+ promptString ) ;
239
+ }
224
240
225
241
// Update the stored prompt string if the session is remote
226
242
if ( this . powerShellContext . CurrentRunspace . Location == RunspaceLocation . Remote )
@@ -295,7 +311,7 @@ private async Task StartReplLoop(CancellationToken cancellationToken)
295
311
{
296
312
string commandString = null ;
297
313
298
- this . WritePromptStringToHost ( ) ;
314
+ await this . WritePromptStringToHost ( ) ;
299
315
300
316
try
301
317
{
Original file line number Diff line number Diff line change @@ -103,14 +103,6 @@ public RunspaceDetails CurrentRunspace
103
103
private set ;
104
104
}
105
105
106
- /// <summary>
107
- /// Gets the prompt string for the current runspace.
108
- /// </summary>
109
- public string PromptString
110
- {
111
- get { return this . mostRecentSessionDetails . PromptString ; }
112
- }
113
-
114
106
#endregion
115
107
116
108
#region Constructors
Original file line number Diff line number Diff line change @@ -15,11 +15,6 @@ namespace Microsoft.PowerShell.EditorServices.Session
15
15
/// </summary>
16
16
public class SessionDetails
17
17
{
18
- /// <summary>
19
- /// Gets the current prompt string.
20
- /// </summary>
21
- public string PromptString { get ; internal set ; }
22
-
23
18
/// <summary>
24
19
/// Gets the process ID of the current process.
25
20
/// </summary>
@@ -47,7 +42,6 @@ public SessionDetails(PSObject detailsObject)
47
42
48
43
Hashtable innerHashtable = detailsObject . BaseObject as Hashtable ;
49
44
50
- this . PromptString = innerHashtable [ "prompt" ] as string ?? "PS> " ;
51
45
this . ProcessId = ( int ) innerHashtable [ "processId" ] as int ? ;
52
46
this . ComputerName = innerHashtable [ "computerName" ] as string ;
53
47
this . InstanceId = innerHashtable [ "instanceId" ] as Guid ? ;
@@ -62,7 +56,7 @@ public static PSCommand GetDetailsCommand()
62
56
{
63
57
PSCommand infoCommand = new PSCommand ( ) ;
64
58
infoCommand . AddScript (
65
- "@{ 'prompt' = prompt; ' computerName' = $env:ComputerName; 'processId' = $PID; 'instanceId' = $host.InstanceId }" ) ;
59
+ "@{ 'computerName' = $env:ComputerName; 'processId' = $PID; 'instanceId' = $host.InstanceId }" ) ;
66
60
67
61
return infoCommand ;
68
62
}
You can’t perform that action at this time.
0 commit comments