Skip to content

Commit

Permalink
fix(console): make long locations readable
Browse files Browse the repository at this point in the history
This closes tokio-rs#411.
  • Loading branch information
guerinoni committed Jul 2, 2023
1 parent 2de5b68 commit 6eac933
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions tokio-console/src/view/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,16 @@ impl TaskView {
Span::raw(task.target()),
]));

overview.push(Spans::from(vec![
bold("Location: "),
Span::raw(task.location()),
]));
let title = "Location: ";
let mut m = Span::raw(task.location());
let row_len = m.width() + title.len() + 4;
if row_len > stats_area[0].width.into() {
let diff = row_len - stats_area[0].width as usize;
let location = task.location()[diff..].to_string();
m = Span::raw(format!("...{}", location));
}

overview.push(Spans::from(vec![bold(title), m]));

let total = task.total(now);

Expand Down

0 comments on commit 6eac933

Please sign in to comment.