Skip to content

Commit

Permalink
Merge pull request #15 from simonwiles/fix-14
Browse files Browse the repository at this point in the history
Fix padding off by one
  • Loading branch information
samwho committed Sep 14, 2023
2 parents 8ed33ca + c9fc907 commit 040306c
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ fn print_spacer(mut output: impl Write, args: &Args, last_spacer: &Instant) -> R
let mut dashes: usize = width.0.into();

if args.padding > 0 {
writeln!(output, "{}", "\n".repeat(args.padding))?;
writeln!(output, "{}", "\n".repeat(args.padding - 1))?;
}

let now = OffsetDateTime::now_utc().to_offset(LOCAL_OFFSET.unwrap_or(UtcOffset::UTC));
Expand Down Expand Up @@ -157,7 +157,7 @@ fn print_spacer(mut output: impl Write, args: &Args, last_spacer: &Instant) -> R
}

if args.padding > 0 {
writeln!(output, "{}", "\n".repeat(args.padding))?;
writeln!(output, "{}", "\n".repeat(args.padding - 1))?;
}

Ok(())
Expand Down Expand Up @@ -405,6 +405,32 @@ mod tests {
}
; "single line, right spacer"
)]
#[test_case(
vec![WriteLn("foo"), Sleep(300)],
vec![Line("foo"), Line(""), Spacer, Line("")],
Args {
after: 0.1,
dash: '-',
padding: 1,
no_color: true,
force_color: false,
right: false,
}
; "padding = 1"
)]
#[test_case(
vec![WriteLn("foo"), Sleep(300)],
vec![Line("foo"), Line(""), Line(""), Spacer, Line(""), Line("")],
Args {
after: 0.1,
dash: '-',
padding: 2,
no_color: true,
force_color: false,
right: false,
}
; "padding = 2"
)]
fn test_output(ops: Vec<Op>, out: Vec<Out>, args: Args) -> Result<()> {
let mut total_sleep_ms = 0;
for op in ops.iter() {
Expand Down

0 comments on commit 040306c

Please sign in to comment.