diff options
author | Nemo157 <git@nemo157.com> | 2024-01-26 12:53:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-26 11:53:34 +0000 |
commit | d9c40d6895df0d24909a4b57818886d367c7ff3a (patch) | |
tree | 75aad078fc0295ceef777c5e9d56d07e23a2bfd4 | |
parent | 2e48e21692491baadb5dbe04159a793e8775b33c (diff) |
fix: Skip padding time if it will overflow the allowed prefix length (#1630)
-rw-r--r-- | atuin/src/command/client/search/history_list.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/atuin/src/command/client/search/history_list.rs b/atuin/src/command/client/search/history_list.rs index 31c2ac53..7ae2c3d7 100644 --- a/atuin/src/command/client/search/history_list.rs +++ b/atuin/src/command/client/search/history_list.rs @@ -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); |