-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
🐛Deno.stdin.setRaw(false)
does not disable ENABLE_VIRTUAL_TERMINAL_INPUT
#17866
Comments
@rivy it seems you diagnosed the problem. Would you like to open a PR that fixes it? It would be good to add a unit test for this specific functionality. |
@dsherret , 👋🏻
I'd be happy to... the fix is dead simple. But I'm not fully familiar with the code base, and I don't see where any If you can offer some guidance, I'm happy to submit a PR. On the other hand, if you feel like it's easier to complete yourself, that's reasonable for me as well. |
@rivy I meant just a unit test for this specific functionality, so that could be done by extracting out to current code to a function like: #[cfg(windows)]
fn new_mode(original_mode: DWORD, is_raw: boolean) -> DWORD {
const RAW_MODE_MASK: DWORD = wincon::ENABLE_LINE_INPUT
| wincon::ENABLE_ECHO_INPUT
| wincon::ENABLE_PROCESSED_INPUT;
if is_raw {
original_mode & !RAW_MODE_MASK | wincon::ENABLE_VIRTUAL_TERMINAL_INPUT
} else {
original_mode | RAW_MODE_MASK & !wincon::ENABLE_VIRTUAL_TERMINAL_INPUT
}
} Then adding some tests: #[cfg(test)]
mod test{
use super::*;
#[cfg(windows)]
#[test]
fn test_new_mode() {
assert_eq!(new_mode(..., ...), ....);
// more assertions here...
}
} Then updating the code to the correct behaviour. |
Ah! Sure, I'm happy to do that... I'll have a PR for you by Wednesday. |
@dsherret , @bartlomieju (I saw that you both collaborated on the last change to the ops code.)
Deno.stdin.setRaw(false)
does not disable ENABLE_VIRTUAL_TERMINAL_INPUT. Consequently, usingDeno.stdin.setRaw(true)
in a script always leaves the terminal in "virtual terminal input" mode back at the command line, disabling arrow usage.To show the bug, execute this script:
For the usual CMD shell terminal, the output is ...
For Windows Terminal, the output is ...
Disabling the code below
//=== cut here
will leave the command line with disabled arrow keys (displaying character sequences instead of interpreting the arrows).EDIT:
I'm not sure where the bug is occurring; the deno ops code looks correct.On second look, the problem is in the ops code...deno/runtime/ops/tty.rs
Lines 89 to 93 in d563416
The precedence of
&
is higher than|
, so parentheses are needed and this code should be...The text was updated successfully, but these errors were encountered: