Skip to content

Commit 9290afd

Browse files
committed
With a fix in PSReadLine, we don't have to return a "null" key press
Which wasn't reliable anyway, because it could be translated to different things depending on the system and encodings in use. PSReadLine now just discards any key input after cancellation.
1 parent b703dee commit 9290afd

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

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

+1-12
Original file line numberDiff line numberDiff line change
@@ -875,13 +875,6 @@ private void OnCancelKeyPress(object sender, ConsoleCancelEventArgs args)
875875
}
876876
}
877877

878-
private static readonly ConsoleKeyInfo s_nullKeyInfo = new(
879-
keyChar: ' ',
880-
ConsoleKey.DownArrow,
881-
shift: false,
882-
alt: false,
883-
control: false);
884-
885878
private ConsoleKeyInfo ReadKey(bool intercept)
886879
{
887880
// PSRL doesn't tell us when CtrlC was sent.
@@ -900,11 +893,7 @@ private ConsoleKeyInfo ReadKey(bool intercept)
900893

901894
// TODO: We may want to allow users of PSES to override this method call.
902895
_lastKey = System.Console.ReadKey(intercept);
903-
904-
// TODO: After fixing PSReadLine so that when canceled it doesn't read a key, we can
905-
// stop using s_nullKeyInfo (which is a down arrow so we don't change the buffer
906-
// content). Without this, the sent key press is translated to an @ symbol.
907-
return _readKeyCancellationToken.IsCancellationRequested ? s_nullKeyInfo : _lastKey.Value;
896+
return _lastKey.Value;
908897
}
909898

910899
internal ConsoleKeyInfo ReadKey(bool intercept, CancellationToken cancellationToken)

0 commit comments

Comments
 (0)