Skip to content

Commit

Permalink
chore: fix-up clippy and rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
philtweir committed Dec 29, 2024
1 parent e7da4ad commit 3fc175a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 21 deletions.
14 changes: 9 additions & 5 deletions crates/atuin-client/src/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub struct ThemeDefinitionConfigBlock {
pub parent: Option<String>,
}

use crossterm::style::{Color, ContentStyle, Attributes, Attribute};
use crossterm::style::{Attribute, Attributes, Color, ContentStyle};

// For now, a theme is loaded as a mapping of meanings to colors, but it may be desirable to
// expand that in the future to general styles, so we populate a Meaning->ContentStyle hashmap.
Expand Down Expand Up @@ -237,7 +237,7 @@ impl StyleFactory {
fn from_fg_color_and_attributes(color: Color, attributes: Attributes) -> ContentStyle {
ContentStyle {
foreground_color: Some(color),
attributes: attributes,
attributes,
..ContentStyle::default()
}
}
Expand Down Expand Up @@ -288,7 +288,10 @@ lazy_static! {
),
(
Meaning::Important,
StyleFactory::from_fg_color_and_attributes(Color::White, Attributes::from(Attribute::Bold)),
StyleFactory::from_fg_color_and_attributes(
Color::White,
Attributes::from(Attribute::Bold),
),
),
(Meaning::Muted, StyleFactory::from_fg_color(Color::Grey)),
(Meaning::Base, ContentStyle::default()),
Expand All @@ -298,7 +301,8 @@ lazy_static! {
static ref BUILTIN_THEMES: HashMap<&'static str, Theme> = {
HashMap::from([
("default", HashMap::new()),
("(none)",
(
"(none)",
HashMap::from([
(Meaning::AlertError, ContentStyle::default()),
(Meaning::AlertWarn, ContentStyle::default()),
Expand All @@ -308,7 +312,7 @@ lazy_static! {
(Meaning::Important, ContentStyle::default()),
(Meaning::Muted, ContentStyle::default()),
(Meaning::Base, ContentStyle::default()),
])
]),
),
(
"autumn",
Expand Down
24 changes: 9 additions & 15 deletions crates/atuin/src/command/client/search/inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub fn draw_commands(

let command = Paragraph::new(Text::from(Span::styled(
history.command.clone(),
theme.as_style(Meaning::Important)
theme.as_style(Meaning::Important),
)))
.block(if compact {
Block::new()
Expand Down Expand Up @@ -354,13 +354,13 @@ pub fn input(

#[cfg(test)]
mod tests {
use ratatui::{backend::TestBackend, prelude::*};
use super::draw_ultracompact;
use atuin_client::{
history::{History, HistoryStats, HistoryId},
theme::ThemeManager
history::{History, HistoryId, HistoryStats},
theme::ThemeManager,
};
use ratatui::{backend::TestBackend, prelude::*};
use time::OffsetDateTime;
use super::draw_ultracompact;

fn mock_history_stats() -> (History, HistoryStats) {
let history = History {
Expand All @@ -372,7 +372,7 @@ mod tests {
cwd: "/toot".to_string(),
session: "sesh1".to_string(),
hostname: "hostn".to_string(),
deleted_at: None
deleted_at: None,
};
let next = History {
id: HistoryId::from("test2".to_string()),
Expand All @@ -383,7 +383,7 @@ mod tests {
cwd: "/toot".to_string(),
session: "sesh1".to_string(),
hostname: "hostn".to_string(),
deleted_at: None
deleted_at: None,
};
let prev = History {
id: HistoryId::from("test3".to_string()),
Expand All @@ -394,7 +394,7 @@ mod tests {
cwd: "/toot".to_string(),
session: "sesh1".to_string(),
hostname: "hostn".to_string(),
deleted_at: None
deleted_at: None,
};
let stats = HistoryStats {
next: Some(next.clone()),
Expand All @@ -419,13 +419,7 @@ mod tests {

let mut manager = ThemeManager::new(Some(true), Some("".to_string()));
let theme = manager.load_theme("(none)", None);
let _ = terminal.draw(|f| draw_ultracompact(
f,
chunk,
&history,
&stats,
&theme,
));
let _ = terminal.draw(|f| draw_ultracompact(f, chunk, &history, &stats, &theme));
let mut lines = [" "; 5].map(|l| Line::from(l));
for (n, entry) in [prev, history, next].iter().enumerate() {
let mut l = lines[n].to_string();
Expand Down
2 changes: 1 addition & 1 deletion crates/atuin/src/command/client/search/interactive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1392,7 +1392,7 @@ mod tests {
use crate::command::client::search::engines::{self, SearchState};
use crate::command::client::search::history_list::ListState;

use super::{Compactness, State, InspectingState};
use super::{Compactness, InspectingState, State};

#[test]
fn calc_preview_height_test() {
Expand Down

0 comments on commit 3fc175a

Please sign in to comment.