Skip to content

Commit 1f1220c

Browse files
committed
Don't print extra prompt on cancellation of ReadLine
1 parent 9290afd commit 1f1220c

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/PowerShellEditorServices/Services/PowerShell/Host/PsesInternalHost.cs

+7-9
Original file line numberDiff line numberDiff line change
@@ -617,17 +617,15 @@ private void DoOneRepl(CancellationToken cancellationToken)
617617

618618
// If the user input was empty it's because:
619619
// - the user provided no input
620-
// - the readline task was canceled
621-
// - CtrlC was sent to readline (which does not propagate a cancellation)
620+
// - the ReadLine task was canceled
621+
// - CtrlC was sent to ReadLine (which does not propagate a cancellation)
622622
//
623-
// In any event there's nothing to run in PowerShell, so we just loop back to the prompt again.
624-
// However, we must distinguish the last two scenarios, since PSRL will not print a new line in those cases.
625-
if (string.IsNullOrEmpty(userInput))
623+
// In any event there's nothing to run in PowerShell, so we just loop back to the
624+
// prompt again. However, PSReadLine will not print a newline for CtrlC, so we print
625+
// one, but we do not want to print one if the ReadLine task was canceled.
626+
if (string.IsNullOrEmpty(userInput) && LastKeyWasCtrlC())
626627
{
627-
if (cancellationToken.IsCancellationRequested || LastKeyWasCtrlC())
628-
{
629-
UI.WriteLine();
630-
}
628+
UI.WriteLine();
631629
return;
632630
}
633631

0 commit comments

Comments
 (0)