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
Fix/input suppress output on windows #9459
Fix/input suppress output on windows #9459
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me for interactive use.
Not sure if it can become problematic if you were to run a script containing such an input
in a scripted way.
// clear terminal events | ||
while crossterm::event::poll(Duration::from_secs(0))? { | ||
// If there's an event, read it to remove it from the queue | ||
let _ = crossterm::event::read()?; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if this might become problematic if you try to run the whole thing in a "scripted" way (e.g. through pexpect
or similar tools) if the buffer gets filled quicker than a human would typically type it in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I'll make some tests !
crossterm::terminal::disable_raw_mode()?; | ||
return Err(ShellError::IOError("SIGINT".to_string())); | ||
Ok(Event::Key(k)) => match k.kind { | ||
KeyEventKind::Press | KeyEventKind::Repeat => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
fyi - i tested this on Windows 10 and it fixes the issue described in #9018. Thanks! |
Let's land it to benefit from the obvious fix and revisit any potential edge cases. |
this PR should close #9018
Description
This PR aims to fix the
input
command with--suppress-output
on WindowsThis fixes two separates issues :
input -s "blah :"
still being in the event buffer (need to be cleared before reading keypresses)Tests + Formatting
cargo fmt --all -- --check
✔️cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect -A clippy::result_large_err
✔️cargo test --workspace
✔️cargo run -- crates/nu-std/tests/run.nu
✔️