I'm unsure if this is a bug or I'm using the API wrong, but a canceled ReadAsync causes the next ReadAsync to ignore the next stdin byte, and then behaves normally after that.
To repro, run the below code. Type 'a', wait to allow the cancel, then type 'b' then 'c'. You will see a "c" for step 3, but it should show a "b".
Is there some state that I need to clear after a ReadAsync cancellation?
using static Vezel.Cathode.Terminal;
EnableRawMode();
var buf = new byte[1];
// read key press, works ok
await OutAsync("1: ");
await ReadAsync(buf);
await OutLineAsync((char)buf[0]);
// do a timeout cancel
try
{
var cancel = new CancellationTokenSource();
cancel.CancelAfter(100);
await OutAsync("2: ");
await ReadAsync(buf, cancel.Token);
await OutLineAsync((char)buf[0]);
}
catch (OperationCanceledException)
{
await OutLineAsync("cancel");
}
// this one requires two keypresses
await OutAsync("3: ");
await ReadAsync(buf);
await OutLineAsync((char)buf[0]);
I'm unsure if this is a bug or I'm using the API wrong, but a canceled ReadAsync causes the next ReadAsync to ignore the next stdin byte, and then behaves normally after that.
To repro, run the below code. Type 'a', wait to allow the cancel, then type 'b' then 'c'. You will see a "c" for step 3, but it should show a "b".
Is there some state that I need to clear after a ReadAsync cancellation?