Skip to content

Commit

Permalink
fix: Skip padding time if it will overflow the allowed prefix length (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Nemo157 committed Jan 26, 2024
1 parent 2e48e21 commit d9c40d6
Showing 1 changed file with 4 additions and 4 deletions.
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

0 comments on commit d9c40d6

Please sign in to comment.