Resolve clippy warnings introduced this round

- AppearanceSettings derives Default instead of carrying a manual impl
  that's identical to the derived one.
- topbar::render_lock_or_search collapses the duplicated Search arms
  into a single fallback so clippy stops flagging identical blocks.
- command_overlay row helpers bundle id/title/hint/keys into a small
  CommandRowContent struct so render_row, render_row_with_glyph, and
  render_row_inner stay under the 7-arg threshold without losing any
  call-site clarity.
This commit is contained in:
2026-05-09 19:08:19 -04:00
parent 68e784daf8
commit 3856c2ea70
3 changed files with 34 additions and 40 deletions
@@ -175,12 +175,14 @@ fn render_tab_rows(tabs: Vec<&BrowserTab>, cx: &mut Context<ElyShell>) -> AnyEle
let initial = title.chars().next().unwrap_or('?').to_string();
render_row_with_glyph(
format!("cmd-tab-{index}"),
CommandRowContent {
id: format!("cmd-tab-{index}"),
title,
hint: Some(host_label),
keys: None,
},
host.as_deref(),
&initial,
title,
Some(host_label),
None,
cx,
move |shell, window, cx| {
shell.select_tab(&tab_id, window, cx);
@@ -208,12 +210,14 @@ fn render_history_rows(
let initial = title.chars().next().unwrap_or('?').to_string();
render_row_with_glyph(
format!("cmd-history-{index}"),
CommandRowContent {
id: format!("cmd-history-{index}"),
title,
hint: Some(display),
keys: None,
},
host.as_deref(),
&initial,
title,
Some(display),
None,
cx,
move |shell, window, cx| {
shell.open_internal_tab(url.as_str(), window, cx);
@@ -291,11 +295,13 @@ fn render_action_rows(
let icon = action.icon.clone();
render_row(
format!("cmd-action-{index}"),
icon,
action.title.to_string(),
Some(action.hint.to_string()),
CommandRowContent {
id: format!("cmd-action-{index}"),
title: action.title.to_string(),
hint: Some(action.hint.to_string()),
keys,
},
icon,
cx,
move |shell, window, cx| {
shell.open_internal_tab(route, window, cx);
@@ -306,12 +312,16 @@ fn render_action_rows(
.into_any_element()
}
fn render_row<F>(
struct CommandRowContent {
id: String,
icon: IconName,
title: String,
hint: Option<String>,
keys: Option<String>,
}
fn render_row<F>(
content: CommandRowContent,
icon: IconName,
cx: &mut Context<ElyShell>,
handler: F,
) -> AnyElement
@@ -328,16 +338,13 @@ where
.text_color(rgb(colors::INK_2))
.child(icon)
.into_any_element();
render_row_inner(id, leading, title, hint, keys, cx, handler)
render_row_inner(content, leading, cx, handler)
}
fn render_row_with_glyph<F>(
id: String,
content: CommandRowContent,
host: Option<&str>,
fallback_initial: &str,
title: String,
hint: Option<String>,
keys: Option<String>,
cx: &mut Context<ElyShell>,
handler: F,
) -> AnyElement
@@ -345,21 +352,20 @@ where
F: Fn(&mut ElyShell, &mut gpui::Window, &mut Context<ElyShell>) + 'static,
{
let leading = render_glyph_for(host, fallback_initial, 24.0);
render_row_inner(id, leading, title, hint, keys, cx, handler)
render_row_inner(content, leading, cx, handler)
}
fn render_row_inner<F>(
id: String,
content: CommandRowContent,
leading: AnyElement,
title: String,
hint: Option<String>,
keys: Option<String>,
cx: &mut Context<ElyShell>,
handler: F,
) -> AnyElement
where
F: Fn(&mut ElyShell, &mut gpui::Window, &mut Context<ElyShell>) + 'static,
{
let CommandRowContent { id, title, hint, keys } = content;
div()
.id(SharedString::from(id))
.flex()
+3 -5
View File
@@ -166,12 +166,10 @@ fn render_styled_url(active_tab: &BrowserTab) -> AnyElement {
}
fn render_lock_or_search(secure: bool, show_styled: bool) -> AnyElement {
let icon = if !show_styled {
IconName::Search
} else if secure {
IconName::Search
} else {
let icon = if show_styled && !secure {
IconName::Globe
} else {
IconName::Search
};
div()
.text_color(rgb(colors::INK_3))
+1 -11
View File
@@ -19,23 +19,13 @@ pub enum ThemeMode {
Dark,
}
#[derive(Clone, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
pub struct AppearanceSettings {
wallpaper: WallpaperTheme,
theme_mode: ThemeMode,
reduce_motion: bool,
}
impl Default for AppearanceSettings {
fn default() -> Self {
Self {
wallpaper: WallpaperTheme::default(),
theme_mode: ThemeMode::default(),
reduce_motion: false,
}
}
}
impl AppearanceSettings {
pub fn wallpaper(&self) -> WallpaperTheme {
self.wallpaper