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:
@@ -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();
|
let initial = title.chars().next().unwrap_or('?').to_string();
|
||||||
|
|
||||||
render_row_with_glyph(
|
render_row_with_glyph(
|
||||||
format!("cmd-tab-{index}"),
|
CommandRowContent {
|
||||||
|
id: format!("cmd-tab-{index}"),
|
||||||
|
title,
|
||||||
|
hint: Some(host_label),
|
||||||
|
keys: None,
|
||||||
|
},
|
||||||
host.as_deref(),
|
host.as_deref(),
|
||||||
&initial,
|
&initial,
|
||||||
title,
|
|
||||||
Some(host_label),
|
|
||||||
None,
|
|
||||||
cx,
|
cx,
|
||||||
move |shell, window, cx| {
|
move |shell, window, cx| {
|
||||||
shell.select_tab(&tab_id, 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();
|
let initial = title.chars().next().unwrap_or('?').to_string();
|
||||||
|
|
||||||
render_row_with_glyph(
|
render_row_with_glyph(
|
||||||
format!("cmd-history-{index}"),
|
CommandRowContent {
|
||||||
|
id: format!("cmd-history-{index}"),
|
||||||
|
title,
|
||||||
|
hint: Some(display),
|
||||||
|
keys: None,
|
||||||
|
},
|
||||||
host.as_deref(),
|
host.as_deref(),
|
||||||
&initial,
|
&initial,
|
||||||
title,
|
|
||||||
Some(display),
|
|
||||||
None,
|
|
||||||
cx,
|
cx,
|
||||||
move |shell, window, cx| {
|
move |shell, window, cx| {
|
||||||
shell.open_internal_tab(url.as_str(), window, cx);
|
shell.open_internal_tab(url.as_str(), window, cx);
|
||||||
@@ -291,11 +295,13 @@ fn render_action_rows(
|
|||||||
let icon = action.icon.clone();
|
let icon = action.icon.clone();
|
||||||
|
|
||||||
render_row(
|
render_row(
|
||||||
format!("cmd-action-{index}"),
|
CommandRowContent {
|
||||||
icon,
|
id: format!("cmd-action-{index}"),
|
||||||
action.title.to_string(),
|
title: action.title.to_string(),
|
||||||
Some(action.hint.to_string()),
|
hint: Some(action.hint.to_string()),
|
||||||
keys,
|
keys,
|
||||||
|
},
|
||||||
|
icon,
|
||||||
cx,
|
cx,
|
||||||
move |shell, window, cx| {
|
move |shell, window, cx| {
|
||||||
shell.open_internal_tab(route, window, cx);
|
shell.open_internal_tab(route, window, cx);
|
||||||
@@ -306,12 +312,16 @@ fn render_action_rows(
|
|||||||
.into_any_element()
|
.into_any_element()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_row<F>(
|
struct CommandRowContent {
|
||||||
id: String,
|
id: String,
|
||||||
icon: IconName,
|
|
||||||
title: String,
|
title: String,
|
||||||
hint: Option<String>,
|
hint: Option<String>,
|
||||||
keys: Option<String>,
|
keys: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn render_row<F>(
|
||||||
|
content: CommandRowContent,
|
||||||
|
icon: IconName,
|
||||||
cx: &mut Context<ElyShell>,
|
cx: &mut Context<ElyShell>,
|
||||||
handler: F,
|
handler: F,
|
||||||
) -> AnyElement
|
) -> AnyElement
|
||||||
@@ -328,16 +338,13 @@ where
|
|||||||
.text_color(rgb(colors::INK_2))
|
.text_color(rgb(colors::INK_2))
|
||||||
.child(icon)
|
.child(icon)
|
||||||
.into_any_element();
|
.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>(
|
fn render_row_with_glyph<F>(
|
||||||
id: String,
|
content: CommandRowContent,
|
||||||
host: Option<&str>,
|
host: Option<&str>,
|
||||||
fallback_initial: &str,
|
fallback_initial: &str,
|
||||||
title: String,
|
|
||||||
hint: Option<String>,
|
|
||||||
keys: Option<String>,
|
|
||||||
cx: &mut Context<ElyShell>,
|
cx: &mut Context<ElyShell>,
|
||||||
handler: F,
|
handler: F,
|
||||||
) -> AnyElement
|
) -> AnyElement
|
||||||
@@ -345,21 +352,20 @@ where
|
|||||||
F: Fn(&mut ElyShell, &mut gpui::Window, &mut Context<ElyShell>) + 'static,
|
F: Fn(&mut ElyShell, &mut gpui::Window, &mut Context<ElyShell>) + 'static,
|
||||||
{
|
{
|
||||||
let leading = render_glyph_for(host, fallback_initial, 24.0);
|
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>(
|
fn render_row_inner<F>(
|
||||||
id: String,
|
content: CommandRowContent,
|
||||||
leading: AnyElement,
|
leading: AnyElement,
|
||||||
title: String,
|
|
||||||
hint: Option<String>,
|
|
||||||
keys: Option<String>,
|
|
||||||
cx: &mut Context<ElyShell>,
|
cx: &mut Context<ElyShell>,
|
||||||
handler: F,
|
handler: F,
|
||||||
) -> AnyElement
|
) -> AnyElement
|
||||||
where
|
where
|
||||||
F: Fn(&mut ElyShell, &mut gpui::Window, &mut Context<ElyShell>) + 'static,
|
F: Fn(&mut ElyShell, &mut gpui::Window, &mut Context<ElyShell>) + 'static,
|
||||||
{
|
{
|
||||||
|
let CommandRowContent { id, title, hint, keys } = content;
|
||||||
|
|
||||||
div()
|
div()
|
||||||
.id(SharedString::from(id))
|
.id(SharedString::from(id))
|
||||||
.flex()
|
.flex()
|
||||||
|
|||||||
@@ -166,12 +166,10 @@ fn render_styled_url(active_tab: &BrowserTab) -> AnyElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn render_lock_or_search(secure: bool, show_styled: bool) -> AnyElement {
|
fn render_lock_or_search(secure: bool, show_styled: bool) -> AnyElement {
|
||||||
let icon = if !show_styled {
|
let icon = if show_styled && !secure {
|
||||||
IconName::Search
|
|
||||||
} else if secure {
|
|
||||||
IconName::Search
|
|
||||||
} else {
|
|
||||||
IconName::Globe
|
IconName::Globe
|
||||||
|
} else {
|
||||||
|
IconName::Search
|
||||||
};
|
};
|
||||||
div()
|
div()
|
||||||
.text_color(rgb(colors::INK_3))
|
.text_color(rgb(colors::INK_3))
|
||||||
|
|||||||
@@ -19,23 +19,13 @@ pub enum ThemeMode {
|
|||||||
Dark,
|
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 {
|
pub struct AppearanceSettings {
|
||||||
wallpaper: WallpaperTheme,
|
wallpaper: WallpaperTheme,
|
||||||
theme_mode: ThemeMode,
|
theme_mode: ThemeMode,
|
||||||
reduce_motion: bool,
|
reduce_motion: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for AppearanceSettings {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self {
|
|
||||||
wallpaper: WallpaperTheme::default(),
|
|
||||||
theme_mode: ThemeMode::default(),
|
|
||||||
reduce_motion: false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl AppearanceSettings {
|
impl AppearanceSettings {
|
||||||
pub fn wallpaper(&self) -> WallpaperTheme {
|
pub fn wallpaper(&self) -> WallpaperTheme {
|
||||||
self.wallpaper
|
self.wallpaper
|
||||||
|
|||||||
Reference in New Issue
Block a user