Skip to content

With a fix in PSReadLine, we don't have to return a "null" key press #1758

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

Merged
merged 1 commit into from
Apr 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"Version": "1.1.3"
},
"PSReadLine": {
"Version": "2.2.2"
"Version": "2.2.3"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1022,13 +1022,6 @@ private void OnCancelKeyPress(object sender, ConsoleCancelEventArgs args)
}
}

private static readonly ConsoleKeyInfo s_nullKeyInfo = new(
keyChar: ' ',
ConsoleKey.DownArrow,
shift: false,
alt: false,
control: false);

private ConsoleKeyInfo ReadKey(bool intercept)
{
// PSRL doesn't tell us when CtrlC was sent.
Expand All @@ -1047,11 +1040,7 @@ private ConsoleKeyInfo ReadKey(bool intercept)

// TODO: We may want to allow users of PSES to override this method call.
_lastKey = System.Console.ReadKey(intercept);

// TODO: After fixing PSReadLine so that when canceled it doesn't read a key, we can
// stop using s_nullKeyInfo (which is a down arrow so we don't change the buffer
// content). Without this, the sent key press is translated to an @ symbol.
return _readKeyCancellationToken.IsCancellationRequested ? s_nullKeyInfo : _lastKey.Value;
return _lastKey.Value;
}

internal ConsoleKeyInfo ReadKey(bool intercept, CancellationToken cancellationToken)
Expand Down