diff --git a/helix-tui/src/terminal.rs b/helix-tui/src/terminal.rs index 72f38d7177d7..e05f7b1fb9a9 100644 --- a/helix-tui/src/terminal.rs +++ b/helix-tui/src/terminal.rs @@ -80,7 +80,7 @@ where /// Wrapper around Terminal initialization. Each buffer is initialized with a blank string and /// default colors for the foreground and the background pub fn new(backend: B) -> io::Result> { - let size = backend.size()?; + let size = nonempty_terminal_size(backend.size()); Terminal::with_options( backend, TerminalOptions { @@ -236,6 +236,13 @@ where /// Queries the real size of the backend. pub fn size(&self) -> io::Result { - self.backend.size() + Ok(nonempty_terminal_size(self.backend.size())) } } + +fn nonempty_terminal_size(size: io::Result) -> Rect { + size.unwrap_or_else(|e| { + log::warn!("{}. Using default terminal size", e); + Rect::new(0, 0, 80, 24) + }) +}