diff --git a/src/PowerShellEditorServices/Services/PowerShellContext/PowerShellContextService.cs b/src/PowerShellEditorServices/Services/PowerShellContext/PowerShellContextService.cs index 599453546..6262c1a7e 100644 --- a/src/PowerShellEditorServices/Services/PowerShellContext/PowerShellContextService.cs +++ b/src/PowerShellEditorServices/Services/PowerShellContext/PowerShellContextService.cs @@ -199,7 +199,7 @@ public static PowerShellContextService Create( EditorServicesPSHostUserInterface hostUserInterface = hostStartupInfo.ConsoleReplEnabled - ? (EditorServicesPSHostUserInterface) new TerminalPSHostUserInterface(powerShellContext, hostStartupInfo.PSHost, shouldUsePSReadLine, logger) + ? (EditorServicesPSHostUserInterface) new TerminalPSHostUserInterface(powerShellContext, hostStartupInfo.PSHost, logger) : new ProtocolPSHostUserInterface(languageServer, powerShellContext, logger); EditorServicesPSHost psHost = diff --git a/src/PowerShellEditorServices/Services/PowerShellContext/Session/Host/EditorServicesPSHostUserInterface.cs b/src/PowerShellEditorServices/Services/PowerShellContext/Session/Host/EditorServicesPSHostUserInterface.cs index 1c23dabb7..a404398ce 100644 --- a/src/PowerShellEditorServices/Services/PowerShellContext/Session/Host/EditorServicesPSHostUserInterface.cs +++ b/src/PowerShellEditorServices/Services/PowerShellContext/Session/Host/EditorServicesPSHostUserInterface.cs @@ -35,7 +35,6 @@ public abstract class EditorServicesPSHostUserInterface : private readonly ConcurrentDictionary currentProgressMessages = new ConcurrentDictionary(); - private readonly bool _isPSReadLineEnabled; private PromptHandler activePromptHandler; private PSHostRawUserInterface rawUserInterface; private CancellationTokenSource commandLoopCancellationToken; @@ -106,13 +105,11 @@ public abstract class EditorServicesPSHostUserInterface : public EditorServicesPSHostUserInterface( PowerShellContextService powerShellContext, PSHostRawUserInterface rawUserInterface, - bool isPSReadLineEnabled, ILogger logger) { this.Logger = logger; this.powerShellContext = powerShellContext; this.rawUserInterface = rawUserInterface; - _isPSReadLineEnabled = isPSReadLineEnabled; this.powerShellContext.DebuggerStop += PowerShellContext_DebuggerStop; this.powerShellContext.DebuggerResumed += PowerShellContext_DebuggerResumed; @@ -812,7 +809,6 @@ private async Task StartReplLoopAsync(CancellationToken cancellationToken) while (!cancellationToken.IsCancellationRequested) { string commandString = null; - int originalCursorTop = 0; try { @@ -825,7 +821,6 @@ private async Task StartReplLoopAsync(CancellationToken cancellationToken) try { - originalCursorTop = await ConsoleProxy.GetCursorTopAsync(cancellationToken).ConfigureAwait(false); commandString = await this.ReadCommandLineAsync(cancellationToken).ConfigureAwait(false); } catch (PipelineStoppedException) @@ -852,13 +847,14 @@ private async Task StartReplLoopAsync(CancellationToken cancellationToken) } finally { - // This supplies the newline in the Legacy ReadLine when executing code in the terminal via hitting the ENTER key. - // Without this, hitting ENTER with a no input looks like it does nothing (no new prompt is written) + // This supplies the newline in the Legacy ReadLine when executing code in the terminal via hitting the ENTER key + // or Ctrl+C. Without this, hitting ENTER with a no input looks like it does nothing (no new prompt is written) // and also the output would show up on the same line as the code you wanted to execute (the prompt line). - // Since PSReadLine handles ENTER internally to itself, we only want to do this when using the Legacy ReadLine. - if (!_isPSReadLineEnabled && - !cancellationToken.IsCancellationRequested && - originalCursorTop == await ConsoleProxy.GetCursorTopAsync(cancellationToken).ConfigureAwait(false)) + // This is AlSO applied to PSReadLine for the Ctrl+C scenario which appears like it does nothing... + // TODO: This still gives an extra newline when you hit ENTER in the PSReadLine experience. We should figure + // out if there's any way to avoid that... but unfortunately, in both scenarios, we only see that empty + // string is returned. + if (!cancellationToken.IsCancellationRequested) { this.WriteLine(); } diff --git a/src/PowerShellEditorServices/Services/PowerShellContext/Session/Host/ProtocolPSHostUserInterface.cs b/src/PowerShellEditorServices/Services/PowerShellContext/Session/Host/ProtocolPSHostUserInterface.cs index 32415922e..b45f0d4a4 100644 --- a/src/PowerShellEditorServices/Services/PowerShellContext/Session/Host/ProtocolPSHostUserInterface.cs +++ b/src/PowerShellEditorServices/Services/PowerShellContext/Session/Host/ProtocolPSHostUserInterface.cs @@ -33,7 +33,6 @@ public ProtocolPSHostUserInterface( : base ( powerShellContext, new SimplePSHostRawUserInterface(logger), - isPSReadLineEnabled: false, logger) { _languageServer = languageServer; diff --git a/src/PowerShellEditorServices/Services/PowerShellContext/Session/Host/TerminalPSHostUserInterface.cs b/src/PowerShellEditorServices/Services/PowerShellContext/Session/Host/TerminalPSHostUserInterface.cs index ce6edee46..20e5398c4 100644 --- a/src/PowerShellEditorServices/Services/PowerShellContext/Session/Host/TerminalPSHostUserInterface.cs +++ b/src/PowerShellEditorServices/Services/PowerShellContext/Session/Host/TerminalPSHostUserInterface.cs @@ -38,12 +38,10 @@ public class TerminalPSHostUserInterface : EditorServicesPSHostUserInterface public TerminalPSHostUserInterface( PowerShellContextService powerShellContext, PSHost internalHost, - bool isPSReadLineEnabled, ILogger logger) : base ( powerShellContext, new TerminalPSHostRawUserInterface(logger, internalHost), - isPSReadLineEnabled, logger) { this.internalHostUI = internalHost.UI;