Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,22 @@ fn show_cursor() {

fn update_term_line(lhs: &str, rhs: &str) {
let width = terminal_size()
.map(|(width, _height)| width.0)
.map(|(width, _height)| usize::from(width.0))
.unwrap_or(80);
let spc = " ".repeat(usize::from(width) - lhs.chars().count() - rhs.chars().count());
print!("\r{lhs}{spc}{rhs}");
let lhs_c = lhs.chars().count();
let rhs_c = rhs.chars().count();
if lhs_c + 1 + rhs_c <= width {
let spc = " ".repeat(width - lhs.chars().count() - rhs.chars().count());
print!("\r{lhs}{spc}{rhs}");
} else if width < rhs_c + 1 {
// If the user's got a ludicrously narrow terminal, nothing we do will work very well, so
// don't try hard.
print!("\r{lhs} {rhs}");
} else {
// If the terminal is a bit too narrow, chop the LHS down and retain all of the RHS.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is actually chopping the rhs off? i.e. the oldest iteration times seem to be kept.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's chopping the RHS of the LHS. We could be more clever here, but it would be diminishing returns.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, i see. Sorry, misunderstood the comment then.

This behaviour is fine.

let lhs_cutdown = lhs.chars().take(width - rhs_c - 1).collect::<String>();
print!("\r{lhs_cutdown} {rhs}");
}
}

/// Run a suite with the specified executor.
Expand Down