Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Skip padding time if it will overflow the allowed prefix length #1630

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions atuin/src/command/client/search/history_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@ impl DrawState<'_> {
let time = format_duration(since.try_into().unwrap_or_default());

// pad the time a little bit before we write. this aligns things nicely
self.draw(
&SPACES[..((PREFIX_LENGTH - self.x) as usize - 4 - time.len())],
Style::default(),
);
// skip padding if for some reason it is already too long to align nicely
let padding =
usize::from(PREFIX_LENGTH).saturating_sub(usize::from(self.x) + 4 + time.len());
self.draw(&SPACES[..padding], Style::default());

self.draw(&time, style);
self.draw(" ago", style);
Expand Down