From 3856c2ea7053410ec217e763db6e648b0b46b418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Sat, 9 May 2026 19:08:19 -0400 Subject: [PATCH] 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. --- .../src/shell/chrome/command_overlay.rs | 54 ++++++++++--------- crates/ely_app/src/shell/chrome/topbar.rs | 8 ++- crates/ely_domain/src/appearance.rs | 12 +---- 3 files changed, 34 insertions(+), 40 deletions(-) diff --git a/crates/ely_app/src/shell/chrome/command_overlay.rs b/crates/ely_app/src/shell/chrome/command_overlay.rs index 6b85488..8ba46f0 100644 --- a/crates/ely_app/src/shell/chrome/command_overlay.rs +++ b/crates/ely_app/src/shell/chrome/command_overlay.rs @@ -175,12 +175,14 @@ fn render_tab_rows(tabs: Vec<&BrowserTab>, cx: &mut Context) -> 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}"), + CommandRowContent { + id: format!("cmd-action-{index}"), + title: action.title.to_string(), + hint: Some(action.hint.to_string()), + keys, + }, icon, - action.title.to_string(), - Some(action.hint.to_string()), - keys, 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( +struct CommandRowContent { id: String, - icon: IconName, title: String, hint: Option, keys: Option, +} + +fn render_row( + content: CommandRowContent, + icon: IconName, cx: &mut Context, 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( - id: String, + content: CommandRowContent, host: Option<&str>, fallback_initial: &str, - title: String, - hint: Option, - keys: Option, cx: &mut Context, handler: F, ) -> AnyElement @@ -345,21 +352,20 @@ where F: Fn(&mut ElyShell, &mut gpui::Window, &mut Context) + '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( - id: String, + content: CommandRowContent, leading: AnyElement, - title: String, - hint: Option, - keys: Option, cx: &mut Context, handler: F, ) -> AnyElement where F: Fn(&mut ElyShell, &mut gpui::Window, &mut Context) + 'static, { + let CommandRowContent { id, title, hint, keys } = content; + div() .id(SharedString::from(id)) .flex() diff --git a/crates/ely_app/src/shell/chrome/topbar.rs b/crates/ely_app/src/shell/chrome/topbar.rs index 6e5ccb5..579eb90 100644 --- a/crates/ely_app/src/shell/chrome/topbar.rs +++ b/crates/ely_app/src/shell/chrome/topbar.rs @@ -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)) diff --git a/crates/ely_domain/src/appearance.rs b/crates/ely_domain/src/appearance.rs index 341805a..e2e3b66 100644 --- a/crates/ely_domain/src/appearance.rs +++ b/crates/ely_domain/src/appearance.rs @@ -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