mirror of
https://github.com/notohh/rustlings.git
synced 2024-12-17 22:58:08 -05:00
Add error message when unable to get terminal size
This commit is contained in:
parent
dcad002057
commit
bcc2a136c8
2 changed files with 3 additions and 3 deletions
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue