Skip to content

Commit 58a6db5

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 a62d6bc commit 58a6db5

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
@@ -1009,13 +1009,6 @@ private void OnCancelKeyPress(object sender, ConsoleCancelEventArgs args)
10091009
}
10101010
}
10111011

1012-
private static readonly ConsoleKeyInfo s_nullKeyInfo = new(
1013-
keyChar: ' ',
1014-
ConsoleKey.DownArrow,
1015-
shift: false,
1016-
alt: false,
1017-
control: false);
1018-
10191012
private ConsoleKeyInfo ReadKey(bool intercept)
10201013
{
10211014
// PSRL doesn't tell us when CtrlC was sent.
@@ -1034,11 +1027,7 @@ private ConsoleKeyInfo ReadKey(bool intercept)
10341027

10351028
// TODO: We may want to allow users of PSES to override this method call.
10361029
_lastKey = System.Console.ReadKey(intercept);
1037-
1038-
// TODO: After fixing PSReadLine so that when canceled it doesn't read a key, we can
1039-
// stop using s_nullKeyInfo (which is a down arrow so we don't change the buffer
1040-
// content). Without this, the sent key press is translated to an @ symbol.
1041-
return _readKeyCancellationToken.IsCancellationRequested ? s_nullKeyInfo : _lastKey.Value;
1030+
return _lastKey.Value;
10421031
}
10431032

10441033
internal ConsoleKeyInfo ReadKey(bool intercept, CancellationToken cancellationToken)

0 commit comments

Comments
 (0)