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
match self.context_page {
ContextPage::ColorSchemes(color_scheme_kind) => {
if let ContextPage::ColorSchemes(color_scheme_kind) = self.context_page {
self.color_scheme_errors.clear();
self.color_scheme_expanded = None;
self.color_scheme_renaming = None;
@ -2350,8 +2349,6 @@ impl Application for App {
ColorSchemeKind::Light => light_entity,
});
}
_ => {}
}
self.set_context_title(context_page.title());
}
@ -2449,8 +2446,7 @@ impl Application for App {
.get(&pane)
.cloned()
.unwrap_or_else(widget::Id::unique);
match tab_model.data::<Mutex<Terminal>>(entity) {
Some(terminal) => {
if let Some(terminal) = tab_model.data::<Mutex<Terminal>>(entity) {
let mut terminal_box = terminal_box(terminal)
.id(terminal_id)
.on_context_menu(move |position_opt| {
@ -2460,8 +2456,7 @@ impl Application for App {
.padding(space_xxs);
if self.config.focus_follow_mouse {
terminal_box =
terminal_box.on_mouse_enter(move || Message::MouseEnter(pane));
terminal_box = terminal_box.on_mouse_enter(move || Message::MouseEnter(pane));
}
let context_menu = {
@ -2478,10 +2473,6 @@ impl Application for App {
};
tab_column = tab_column.push(tab_element);
}
None => {
//TODO
}
}
//Only draw find in the currently focused pane
if self.find && pane == self.pane_model.focus {
@ -2538,6 +2529,8 @@ impl Application for App {
tab_column = tab_column
.push(widget::layer_container(find_widget).layer(cosmic_theme::Layer::Primary));
} else {
// TODO
}
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 {
Color::Named(named_color) => match colors[named_color] {
Some(rgb) => rgb,
None => match named_color {
NamedColor::Background => {
None => {
if named_color == NamedColor::Background {
// Allow using an unset background
return cosmic_text::Color(WINDOW_BG_COLOR.load(Ordering::SeqCst));
}
_ => {
} else {
log::warn!("missing named color {:?}", named_color);
Rgb::default()
}
},
}
},
Color::Spec(rgb) => rgb,
Color::Indexed(index) => match colors[index as usize] {
Some(rgb) => rgb,
None => {
Color::Indexed(index) => {
if let Some(rgb) = colors[index as usize] {
rgb
} else {
log::warn!("missing indexed color {}", index);
Rgb::default()
}
},
}
};
cosmic_text::Color::rgb(rgb.r, rgb.g, rgb.b)
}