crossterm-rs / crossterm

Cross platform terminal library rust
MIT License
3.29k stars 280 forks source link

`crossterm::terminal::size()` contains `u16::MAX` under some conditions on Windows #786

Open jiftoo opened 1 year ago

jiftoo commented 1 year ago

If you drag the bottom of the cmd.exe window to the top repeatedly, sometimes the following code panics with the message "attempt to add with overflow".

// pretend this is run on every event::read()
//
let stdout = std::io::stdout();
let (width, height) = term::size()?; // height == 65535 when the cmd.exe window is height 0 sometimes
for _ in 0..height - 2 {
    term::queue!(
        stdout,
        term::MoveToColumn(0),
        term::Print('║'),
        term::MoveToColumn(left_pane_width - 1),
        term::Print('║'),
        term::MoveToNextLine(1)
    )?;
}

I'm not sure if this is expected behaviour.

nissaofthesea commented 1 year ago

does the panic message say the location of the panic (file, line number, column)?