@@ -35,7 +35,6 @@ public abstract class EditorServicesPSHostUserInterface :
35
35
private readonly ConcurrentDictionary < ProgressKey , object > currentProgressMessages =
36
36
new ConcurrentDictionary < ProgressKey , object > ( ) ;
37
37
38
- private readonly bool _isPSReadLineEnabled ;
39
38
private PromptHandler activePromptHandler ;
40
39
private PSHostRawUserInterface rawUserInterface ;
41
40
private CancellationTokenSource commandLoopCancellationToken ;
@@ -106,13 +105,11 @@ public abstract class EditorServicesPSHostUserInterface :
106
105
public EditorServicesPSHostUserInterface (
107
106
PowerShellContextService powerShellContext ,
108
107
PSHostRawUserInterface rawUserInterface ,
109
- bool isPSReadLineEnabled ,
110
108
ILogger logger )
111
109
{
112
110
this . Logger = logger ;
113
111
this . powerShellContext = powerShellContext ;
114
112
this . rawUserInterface = rawUserInterface ;
115
- _isPSReadLineEnabled = isPSReadLineEnabled ;
116
113
117
114
this . powerShellContext . DebuggerStop += PowerShellContext_DebuggerStop ;
118
115
this . powerShellContext . DebuggerResumed += PowerShellContext_DebuggerResumed ;
@@ -808,7 +805,6 @@ private async Task StartReplLoopAsync(CancellationToken cancellationToken)
808
805
while ( ! cancellationToken . IsCancellationRequested )
809
806
{
810
807
string commandString = null ;
811
- int originalCursorTop = 0 ;
812
808
813
809
try
814
810
{
@@ -821,7 +817,6 @@ private async Task StartReplLoopAsync(CancellationToken cancellationToken)
821
817
822
818
try
823
819
{
824
- originalCursorTop = await ConsoleProxy . GetCursorTopAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
825
820
commandString = await this . ReadCommandLineAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
826
821
}
827
822
catch ( PipelineStoppedException )
@@ -848,13 +843,14 @@ private async Task StartReplLoopAsync(CancellationToken cancellationToken)
848
843
}
849
844
finally
850
845
{
851
- // This supplies the newline in the Legacy ReadLine when executing code in the terminal via hitting the ENTER key.
852
- // Without this, hitting ENTER with a no input looks like it does nothing (no new prompt is written)
846
+ // This supplies the newline in the Legacy ReadLine when executing code in the terminal via hitting the ENTER key
847
+ // or Ctrl+C. Without this, hitting ENTER with a no input looks like it does nothing (no new prompt is written)
853
848
// and also the output would show up on the same line as the code you wanted to execute (the prompt line).
854
- // Since PSReadLine handles ENTER internally to itself, we only want to do this when using the Legacy ReadLine.
855
- if ( ! _isPSReadLineEnabled &&
856
- ! cancellationToken . IsCancellationRequested &&
857
- originalCursorTop == await ConsoleProxy . GetCursorTopAsync ( cancellationToken ) . ConfigureAwait ( false ) )
849
+ // This is AlSO applied to PSReadLine for the Ctrl+C scenario which appears like it does nothing...
850
+ // TODO: This still gives an extra newline when you hit ENTER in the PSReadLine experience. We should figure
851
+ // out if there's any way to avoid that... but unfortunately, in both scenarios, we only see that empty
852
+ // string is returned.
853
+ if ( ! cancellationToken . IsCancellationRequested )
858
854
{
859
855
this . WriteLine ( ) ;
860
856
}
0 commit comments