Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mitigate prompt issue #1178

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public RunspaceDetails CurrentRunspace

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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public abstract class EditorServicesPSHostUserInterface :
private readonly ConcurrentDictionary<ProgressKey, object> currentProgressMessages =
new ConcurrentDictionary<ProgressKey, object>();

private readonly bool _isPSReadLineEnabled;
private PromptHandler activePromptHandler;
private PSHostRawUserInterface rawUserInterface;
private CancellationTokenSource commandLoopCancellationToken;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -852,12 +849,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 &&
// 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 &&
originalCursorTop == await ConsoleProxy.GetCursorTopAsync(cancellationToken).ConfigureAwait(false))
{
this.WriteLine();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ internal class ProtocolPSHostUserInterface : EditorServicesPSHostUserInterface
: base (
powerShellContext,
new SimplePSHostRawUserInterface(logger),
isPSReadLineEnabled: false,
logger)
{
_languageServer = languageServer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down