mirror of
https://github.com/denisidoro/navi
synced 2025-02-16 12:38:28 +00:00
Be more defensive with /dev/tty (#219)
This commit is contained in:
parent
aefc136491
commit
44d072de94
1 changed files with 9 additions and 4 deletions
|
@ -37,11 +37,16 @@ fn width_with_fd() -> u16 {
|
|||
use std::fs;
|
||||
use std::os::unix::io::AsRawFd;
|
||||
|
||||
let file = fs::File::open("/dev/tty").unwrap();
|
||||
let size = terminal_size_using_fd(file.as_raw_fd());
|
||||
let file = fs::File::open("/dev/tty");
|
||||
|
||||
if let Some((Width(w), Height(_))) = size {
|
||||
w
|
||||
if let Ok(f) = file {
|
||||
let size = terminal_size_using_fd(f.as_raw_fd());
|
||||
|
||||
if let Some((Width(w), Height(_))) = size {
|
||||
w
|
||||
} else {
|
||||
width_with_shell_out()
|
||||
}
|
||||
} else {
|
||||
width_with_shell_out()
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue