collapse single match blocks (clippy::single_match, clippy::single_match_else)

This commit is contained in:
Daniel Eades 2024-04-14 20:58:19 +01:00 • committed by Jeremy Soller
parent dcae0a4c2e
commit 011af310d2
2 changed files with 57 additions and 64 deletions

View file

@ -2326,8 +2326,7 @@ impl Application for App {
} }
// Extra work to do to prepare context pages // Extra work to do to prepare context pages
match self.context_page { if let ContextPage::ColorSchemes(color_scheme_kind) = self.context_page {
ContextPage::ColorSchemes(color_scheme_kind) => {
self.color_scheme_errors.clear(); self.color_scheme_errors.clear();
self.color_scheme_expanded = None; self.color_scheme_expanded = None;
self.color_scheme_renaming = None; self.color_scheme_renaming = None;
@ -2350,8 +2349,6 @@ impl Application for App {
ColorSchemeKind::Light => light_entity, ColorSchemeKind::Light => light_entity,
}); });
} }
_ => {}
}
self.set_context_title(context_page.title()); self.set_context_title(context_page.title());
} }
@ -2449,8 +2446,7 @@ impl Application for App {
.get(&pane) .get(&pane)
.cloned() .cloned()
.unwrap_or_else(widget::Id::unique); .unwrap_or_else(widget::Id::unique);
match tab_model.data::<Mutex<Terminal>>(entity) { if let Some(terminal) = tab_model.data::<Mutex<Terminal>>(entity) {
Some(terminal) => {
let mut terminal_box = terminal_box(terminal) let mut terminal_box = terminal_box(terminal)
.id(terminal_id) .id(terminal_id)
.on_context_menu(move |position_opt| { .on_context_menu(move |position_opt| {
@ -2460,8 +2456,7 @@ impl Application for App {
.padding(space_xxs); .padding(space_xxs);
if self.config.focus_follow_mouse { if self.config.focus_follow_mouse {
terminal_box = terminal_box = terminal_box.on_mouse_enter(move || Message::MouseEnter(pane));
terminal_box.on_mouse_enter(move || Message::MouseEnter(pane));
} }
let context_menu = { let context_menu = {
@ -2478,10 +2473,6 @@ impl Application for App {
}; };
tab_column = tab_column.push(tab_element); tab_column = tab_column.push(tab_element);
} }
None => {
//TODO
}
}
//Only draw find in the currently focused pane //Only draw find in the currently focused pane
if self.find && pane == self.pane_model.focus { if self.find && pane == self.pane_model.focus {
@ -2538,6 +2529,8 @@ impl Application for App {
tab_column = tab_column tab_column = tab_column
.push(widget::layer_container(find_widget).layer(cosmic_theme::Layer::Primary)); .push(widget::layer_container(find_widget).layer(cosmic_theme::Layer::Primary));
} else {
// TODO
} }
pane_grid::Content::new(tab_column) pane_grid::Content::new(tab_column)

View file

@ -110,25 +110,25 @@ fn convert_color(colors: &Colors, color: Color) -> cosmic_text::Color {
let rgb = match color { let rgb = match color {
Color::Named(named_color) => match colors[named_color] { Color::Named(named_color) => match colors[named_color] {
Some(rgb) => rgb, Some(rgb) => rgb,
None => match named_color { None => {
NamedColor::Background => { if named_color == NamedColor::Background {
// Allow using an unset background // Allow using an unset background
return cosmic_text::Color(WINDOW_BG_COLOR.load(Ordering::SeqCst)); return cosmic_text::Color(WINDOW_BG_COLOR.load(Ordering::SeqCst));
} } else {
_ => {
log::warn!("missing named color {:?}", named_color); log::warn!("missing named color {:?}", named_color);
Rgb::default() Rgb::default()
} }
}, }
}, },
Color::Spec(rgb) => rgb, Color::Spec(rgb) => rgb,
Color::Indexed(index) => match colors[index as usize] { Color::Indexed(index) => {
Some(rgb) => rgb, if let Some(rgb) = colors[index as usize] {
None => { rgb
} else {
log::warn!("missing indexed color {}", index); log::warn!("missing indexed color {}", index);
Rgb::default() Rgb::default()
} }
}, }
}; };
cosmic_text::Color::rgb(rgb.r, rgb.g, rgb.b) cosmic_text::Color::rgb(rgb.r, rgb.g, rgb.b)
} }