From b64c3eb79b11f08b052121961afb7c80c5744fdf Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sat, 25 Mar 2023 18:58:15 +0100 Subject: [PATCH] termsize.rs: export Termsize --- fish-rust/src/termsize.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/fish-rust/src/termsize.rs b/fish-rust/src/termsize.rs index c5ca55e71..bd87dc8c6 100644 --- a/fish-rust/src/termsize.rs +++ b/fish-rust/src/termsize.rs @@ -32,7 +32,7 @@ mod termsize_ffi { pub fn termsize_handle_winch(); } } -use termsize_ffi::Termsize; +pub use termsize_ffi::Termsize; // A counter which is incremented every SIGWINCH, or when the tty is otherwise invalidated. static TTY_TERMSIZE_GEN_COUNT: AtomicU32 = AtomicU32::new(0); @@ -121,13 +121,9 @@ impl TermsizeData { fn current(&self) -> Termsize { // This encapsulates our ordering logic. If we have a termsize from a tty, use it; otherwise use // what we have seen from the environment. - if let Some(ts) = self.last_from_tty { - ts - } else if let Some(ts) = self.last_from_env { - ts - } else { - Termsize::defaults() - } + self.last_from_tty + .or(self.last_from_env) + .unwrap_or_else(Termsize::defaults) } /// Mark that our termsize is (for the time being) from the environment, not the tty.