crossterm-rs / crossterm

Cross platform terminal library rust
MIT License
3.28k stars 281 forks source link

On MacOS, `crossterm::cursor::position()` freezes the program when stdin is piped #828

Open glcraft opened 1 year ago

glcraft commented 1 year ago

Describe the bug When using crossterm::cursor::position() when stdin comes from another program (piped input), the program freezes and doesn't respond to any other event. When it occurs, it's impossible to quit the program by pressing Ctrl+C. The shell launching the program also get some trouble (nushell blocks, zsh get its size wrong).

The issue is not reproductible on Linux. I haven't tried on Windows yet.

To Reproduce

  1. Minimal code :
    fn main() {
    let current_line_pos = crossterm::cursor::position().unwrap().1;
    }
  2. run the code with piped input : on zsh
    cargo r <<< test

    on nushell

    "test" | cargo r

Expected behavior Not to freeze 😄

OS MacOS Ventura 15.5.2

Terminal/Console Tried on iTerm2 and vscode integrated console. Launched with nushell and zsh.