-
Notifications
You must be signed in to change notification settings - Fork 280
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
The size() is broken on MacOs. #406
Comments
I think the problem with this issue is not TTY in specific. The reading terminal size was implemented in version 0.15.1. You said in discord that 0.16 did not have this issue, that would mean that the city is not the problem here. I think it is a combo of falling back on stdout and using tput/libc. Here is a quick update, I have to go now, will come back at this tomorrow. First:
version 1 0.15: crossterm/src/terminal/sys/unix.rs Line 35 in e35d4d2
let file = File::open("/dev/tty").unwrap();
if let Ok(true) =
wrap_with_result(unsafe { ioctl(file.into_raw_fd(), TIOCGWINSZ.into(), &mut size) })
{
Ok((size.ws_col, size.ws_row))
} else {
tput_size().ok_or_else(|| std::io::Error::last_os_error().into())
} version 2: crossterm/src/terminal/sys/unix.rs Line 35 in e35d4d2
let file = File::open("/dev/tty").unwrap();
if let Ok(true) =
wrap_with_result(unsafe { ioctl(file.into_raw_fd(), TIOCGWINSZ.into(), &mut size) })
{
Ok((size.ws_col, size.ws_row))
} else {
tput_size().ok_or_else(|| std::io::Error::last_os_error().into())
} version 3: crossterm/src/terminal/sys/unix.rs Line 35 in 0070638
let file = File::open("/dev/tty")?;
let fd = FileDesc::new(file.into_raw_fd(), true);
if let Ok(true) = wrap_with_result(unsafe { ioctl(fd.raw_fd(), TIOCGWINSZ.into(), &mut size) })
{
Ok((size.ws_col, size.ws_row))
} else {
tput_size().ok_or_else(|| std::io::Error::last_os_error().into())
} version 4 (0.17): crossterm/src/terminal/sys/unix.rs Line 35 in 52b9d47
let fd = if let Ok(file) = File::open("/dev/tty") {
FileDesc::new(file.into_raw_fd(), true).raw_fd()
} else {
// Fallback to libc::STDOUT_FILENO if /dev/tty is missing
STDOUT_FILENO
};
if let Ok(true) = wrap_with_result(unsafe { ioctl(fd, TIOCGWINSZ.into(), &mut size) }) {
Ok((size.ws_col, size.ws_row))
} else {
tput_size().ok_or_else(|| std::io::Error::last_os_error().into())
} |
After our discord discussion I want to emphasise that I bisected the issue down to one commit that introduced the problem: 52b9d47 the parent of that commit does not show this behaviour. Also when reverting only that commit on current master (or 0.17.1) the problem goes away - the plot thickens. I am no expert on |
Just a quick finding: in 0.16 we went from |
I was having the same problem when I found this issue. I believe I validated this by running a brute-force version that keeps
I'll create a more elegant PR for this fix for you guys to review |
I can confirm #413 fixed this issue. |
Should be fixed in 17.3 |
Describe the bug
commit 52b9d47 broke querying the correct size of the terminal on MacOs aswell as the resize event. The size returned will always be 80x24 and not the actual size.
I am pretty sure this is related to the revert that was necessary to fix the input on Mac aswell in
0.17.1
because it also tries to read "/dev/tty".see the gif as an illustration (note the resize event always returning 80x24 instead of the correct size values):
note: reverting that particular commit fixes the issue
To Reproduce
run the example on Mac and resize the window:
OS
MacOs
Terminal/Shell
Zsh/iTerm
update: clarified that by broken I mean the values for size are not correct.
The text was updated successfully, but these errors were encountered: