fix clippy collapsible match warnings

This commit is contained in:
michel
2026-04-26 12:18:00 +02:00
parent 41d129c6bc
commit e1ee3ac493
+18 -28
View File
@@ -465,8 +465,9 @@ impl MainTui {
fn handle_searches_input(&mut self, key: KeyEvent) -> Result<()> { fn handle_searches_input(&mut self, key: KeyEvent) -> Result<()> {
match key.code { match key.code {
KeyCode::Up | KeyCode::Char('k') => { KeyCode::Up | KeyCode::Char('k')
if !self.state.searches.is_empty() { if !self.state.searches.is_empty() =>
{
let current = let current =
self.state.searches_table_state.selected().unwrap_or(0); self.state.searches_table_state.selected().unwrap_or(0);
let new = if current == 0 { let new = if current == 0 {
@@ -476,15 +477,14 @@ impl MainTui {
}; };
self.state.searches_table_state.select(Some(new)); self.state.searches_table_state.select(Some(new));
} }
} KeyCode::Down | KeyCode::Char('j')
KeyCode::Down | KeyCode::Char('j') => { if !self.state.searches.is_empty() =>
if !self.state.searches.is_empty() { {
let current = let current =
self.state.searches_table_state.selected().unwrap_or(0); self.state.searches_table_state.selected().unwrap_or(0);
let new = (current + 1) % self.state.searches.len(); let new = (current + 1) % self.state.searches.len();
self.state.searches_table_state.select(Some(new)); self.state.searches_table_state.select(Some(new));
} }
}
KeyCode::Enter => { KeyCode::Enter => {
if let Some(selected) = if let Some(selected) =
self.state.searches_table_state.selected() self.state.searches_table_state.selected()
@@ -525,8 +525,7 @@ impl MainTui {
}; };
match key.code { match key.code {
KeyCode::Up | KeyCode::Char('k') => { KeyCode::Up | KeyCode::Char('k') if items_count > 0 => {
if items_count > 0 {
let current = let current =
self.state.results_table_state.selected().unwrap_or(0); self.state.results_table_state.selected().unwrap_or(0);
let new = if current == 0 { let new = if current == 0 {
@@ -536,15 +535,12 @@ impl MainTui {
}; };
self.state.results_table_state.select(Some(new)); self.state.results_table_state.select(Some(new));
} }
} KeyCode::Down | KeyCode::Char('j') if items_count > 0 => {
KeyCode::Down | KeyCode::Char('j') => {
if items_count > 0 {
let current = let current =
self.state.results_table_state.selected().unwrap_or(0); self.state.results_table_state.selected().unwrap_or(0);
let new = (current + 1) % items_count; let new = (current + 1) % items_count;
self.state.results_table_state.select(Some(new)); self.state.results_table_state.select(Some(new));
} }
}
KeyCode::Char(' ') => { KeyCode::Char(' ') => {
if let Some(current) = self.state.results_table_state.selected() if let Some(current) = self.state.results_table_state.selected()
{ {
@@ -596,13 +592,11 @@ impl MainTui {
fn handle_downloads_input(&mut self, key: KeyEvent) -> Result<()> { fn handle_downloads_input(&mut self, key: KeyEvent) -> Result<()> {
match key.code { match key.code {
KeyCode::Up | KeyCode::Char('k') => { KeyCode::Up | KeyCode::Char('k')
if !self.state.downloads.is_empty() { if !self.state.downloads.is_empty() =>
let current = self {
.state let current =
.downloads_table_state self.state.downloads_table_state.selected().unwrap_or(0);
.selected()
.unwrap_or(0);
let new = if current == 0 { let new = if current == 0 {
self.state.downloads.len() - 1 self.state.downloads.len() - 1
} else { } else {
@@ -610,18 +604,14 @@ impl MainTui {
}; };
self.state.downloads_table_state.select(Some(new)); self.state.downloads_table_state.select(Some(new));
} }
} KeyCode::Down | KeyCode::Char('j')
KeyCode::Down | KeyCode::Char('j') => { if !self.state.downloads.is_empty() =>
if !self.state.downloads.is_empty() { {
let current = self let current =
.state self.state.downloads_table_state.selected().unwrap_or(0);
.downloads_table_state
.selected()
.unwrap_or(0);
let new = (current + 1) % self.state.downloads.len(); let new = (current + 1) % self.state.downloads.len();
self.state.downloads_table_state.select(Some(new)); self.state.downloads_table_state.select(Some(new));
} }
}
KeyCode::Char('p') => { KeyCode::Char('p') => {
self.toggle_selected_download_pause(); self.toggle_selected_download_pause();
} }