Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Cancellation on ReadAsync causes next ReadAsync to skip a byte (raw mode) #165

Copy link
Copy link

Description

@scottbilas
Issue body actions

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]);
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: driversIssues related to the terminal drivers.Issues related to the terminal drivers.os: windowsIssues that are specific to Windows (10, 11, etc).Issues that are specific to Windows (10, 11, etc).state: blockedIssues that are blocked on some other issue or work.Issues that are blocked on some other issue or work.

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.