mirror of
https://github.com/atuinsh/atuin.git
synced 2025-06-24 20:01:36 +02:00
fix: Skip padding time if it will overflow the allowed prefix length (#1630)
This commit is contained in:
parent
2e48e21692
commit
d9c40d6895
@ -164,10 +164,10 @@ impl DrawState<'_> {
|
|||||||
let time = format_duration(since.try_into().unwrap_or_default());
|
let time = format_duration(since.try_into().unwrap_or_default());
|
||||||
|
|
||||||
// pad the time a little bit before we write. this aligns things nicely
|
// pad the time a little bit before we write. this aligns things nicely
|
||||||
self.draw(
|
// skip padding if for some reason it is already too long to align nicely
|
||||||
&SPACES[..((PREFIX_LENGTH - self.x) as usize - 4 - time.len())],
|
let padding =
|
||||||
Style::default(),
|
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(&time, style);
|
||||||
self.draw(" ago", style);
|
self.draw(" ago", style);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user