Skip to content

Commit f42f0c9

Browse files
With a fix in PSReadLine, we don't have to return a "null" key press (#1758)
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. This requires an update to PSReadLine v2.2.3.
1 parent 24b5962 commit f42f0c9

File tree

2 files changed

+2
-13
lines changed

2 files changed

+2
-13
lines changed

Diff for: modules.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
"Version": "1.1.3"
77
},
88
"PSReadLine": {
9-
"Version": "2.2.2"
9+
"Version": "2.2.3"
1010
}
1111
}

Diff for: src/PowerShellEditorServices/Services/PowerShell/Host/PsesInternalHost.cs

+1-12
Original file line numberDiff line numberDiff line change
@@ -1022,13 +1022,6 @@ private void OnCancelKeyPress(object sender, ConsoleCancelEventArgs args)
10221022
}
10231023
}
10241024

1025-
private static readonly ConsoleKeyInfo s_nullKeyInfo = new(
1026-
keyChar: ' ',
1027-
ConsoleKey.DownArrow,
1028-
shift: false,
1029-
alt: false,
1030-
control: false);
1031-
10321025
private ConsoleKeyInfo ReadKey(bool intercept)
10331026
{
10341027
// PSRL doesn't tell us when CtrlC was sent.
@@ -1047,11 +1040,7 @@ private ConsoleKeyInfo ReadKey(bool intercept)
10471040

10481041
// TODO: We may want to allow users of PSES to override this method call.
10491042
_lastKey = System.Console.ReadKey(intercept);
1050-
1051-
// TODO: After fixing PSReadLine so that when canceled it doesn't read a key, we can
1052-
// stop using s_nullKeyInfo (which is a down arrow so we don't change the buffer
1053-
// content). Without this, the sent key press is translated to an @ symbol.
1054-
return _readKeyCancellationToken.IsCancellationRequested ? s_nullKeyInfo : _lastKey.Value;
1043+
return _lastKey.Value;
10551044
}
10561045

10571046
internal ConsoleKeyInfo ReadKey(bool intercept, CancellationToken cancellationToken)

0 commit comments

Comments
 (0)