Skip to content

Commit

Permalink
Add error message when unable to get terminal size
Browse files Browse the repository at this point in the history
  • Loading branch information
mo8it committed Sep 5, 2024
1 parent dcad002 commit bcc2a13
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/list/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self> {
pub fn build(app_state: &'a mut AppState, stdout: &mut StdoutLock) -> Result<Self> {
stdout.queue(Clear(ClearType::All))?;

let name_col_title_len = 4;
Expand All @@ -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 {
Expand Down

0 comments on commit bcc2a13

Please sign in to comment.