diff --git a/src/app.rs b/src/app.rs index f61febc..4543cdc 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1,7 +1,7 @@ use std::error; -use tui_input::Input; use ratatui::widgets::ListState; +use tui_input::Input; use crate::api::SearchResult; @@ -73,7 +73,7 @@ impl Default for App { list: ResultList { state: ListState::default(), items: Vec::new(), - last_selected: None + last_selected: None, }, } } diff --git a/src/handler.rs b/src/handler.rs index 3a1faa9..ee59053 100644 --- a/src/handler.rs +++ b/src/handler.rs @@ -15,10 +15,15 @@ pub async fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult< } => { app.quit(); } - KeyEvent { code: KeyCode::Esc, .. } => { + KeyEvent { + code: KeyCode::Esc, .. + } => { app.quit(); } - KeyEvent { code: KeyCode::Enter, .. } => { + KeyEvent { + code: KeyCode::Enter, + .. + } => { app.list = ResultList { state: app.list.state.clone(), items: query_anime(app.input.to_string()).await.unwrap().results, @@ -32,11 +37,11 @@ pub async fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult< } } match key_event.code { - Char('j') | Down => app.list.next(), - Char('k') | Up => app.list.previous(), - Char('g') => app.go_top(), - Char('G') => app.go_bottom(), - _ => {} - } + Char('j') | Down => app.list.next(), + Char('k') | Up => app.list.previous(), + Char('g') => app.go_top(), + Char('G') => app.go_bottom(), + _ => {} + } Ok(()) }