From bcc2a136c8b086a660b8e656c2cd9398f47435f4 Mon Sep 17 00:00:00 2001 From: mo8it Date: Thu, 5 Sep 2024 17:37:34 +0200 Subject: [PATCH] Add error message when unable to get terminal size --- src/list.rs | 2 +- src/list/state.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/list.rs b/src/list.rs index cfd3720c..9f243a17 100644 --- a/src/list.rs +++ b/src/list.rs @@ -20,7 +20,7 @@ mod scroll_state; mod state; fn handle_list(app_state: &mut AppState, stdout: &mut StdoutLock) -> Result<()> { - let mut list_state = ListState::new(app_state, stdout)?; + let mut list_state = ListState::build(app_state, stdout)?; let mut is_searching = false; loop { diff --git a/src/list/state.rs b/src/list/state.rs index ed7c71f6..5bdbca77 100644 --- a/src/list/state.rs +++ b/src/list/state.rs @@ -48,7 +48,7 @@ pub struct ListState<'a> { } impl<'a> ListState<'a> { - pub fn new(app_state: &'a mut AppState, stdout: &mut StdoutLock) -> io::Result { + pub fn build(app_state: &'a mut AppState, stdout: &mut StdoutLock) -> Result { stdout.queue(Clear(ClearType::All))?; let name_col_title_len = 4; @@ -64,7 +64,7 @@ impl<'a> ListState<'a> { let n_rows_with_filter = app_state.exercises().len(); let selected = app_state.current_exercise_ind(); - let (width, height) = terminal::size()?; + let (width, height) = terminal::size().context("Failed to get the terminal size")?; let scroll_state = ScrollState::new(n_rows_with_filter, Some(selected), 5); let mut slf = Self {