Fix zero terminal sizes being treated as ok in Unix (#680)

This commit is contained in:
Siphalor 2022-06-30 21:34:10 +02:00 committed by GitHub
parent ad0d100304
commit f523c110a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,10 +40,11 @@ pub(crate) fn size() -> Result<(u16, u16)> {
};
if wrap_with_result(unsafe { ioctl(fd, TIOCGWINSZ.into(), &mut size) }).is_ok() {
Ok((size.ws_col, size.ws_row))
} else {
tput_size().ok_or_else(|| std::io::Error::last_os_error().into())
if size.ws_col != 0 && size.ws_row != 0 {
return Ok((size.ws_col, size.ws_row));
}
}
tput_size().ok_or_else(|| std::io::Error::last_os_error().into())
}
pub(crate) fn enable_raw_mode() -> Result<()> {