Skip to content

Commit bcc2a13

Browse files
committed
Add error message when unable to get terminal size
1 parent dcad002 commit bcc2a13

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ mod scroll_state;
2020
mod state;
2121

2222
fn handle_list(app_state: &mut AppState, stdout: &mut StdoutLock) -> Result<()> {
23-
let mut list_state = ListState::new(app_state, stdout)?;
23+
let mut list_state = ListState::build(app_state, stdout)?;
2424
let mut is_searching = false;
2525

2626
loop {

src/list/state.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub struct ListState<'a> {
4848
}
4949

5050
impl<'a> ListState<'a> {
51-
pub fn new(app_state: &'a mut AppState, stdout: &mut StdoutLock) -> io::Result<Self> {
51+
pub fn build(app_state: &'a mut AppState, stdout: &mut StdoutLock) -> Result<Self> {
5252
stdout.queue(Clear(ClearType::All))?;
5353

5454
let name_col_title_len = 4;
@@ -64,7 +64,7 @@ impl<'a> ListState<'a> {
6464
let n_rows_with_filter = app_state.exercises().len();
6565
let selected = app_state.current_exercise_ind();
6666

67-
let (width, height) = terminal::size()?;
67+
let (width, height) = terminal::size().context("Failed to get the terminal size")?;
6868
let scroll_state = ScrollState::new(n_rows_with_filter, Some(selected), 5);
6969

7070
let mut slf = Self {

0 commit comments

Comments
 (0)