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 3, 2023
1 parent 2de5b68 commit bba1c6b
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions tokio-console/src/view/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,18 @@ impl TaskView {
Span::raw(task.target()),
]));

overview.push(Spans::from(vec![
bold("Location: "),
Span::raw(task.location()),
]));
let title = "Location: ";
let row_len = task.location().len() + title.len();
let location = if row_len > stats_area[0].width.into() {
// NOTE: 4 is because `...` is added to the front of the location + an extra space.
let diff = row_len + 4 - stats_area[0].width as usize;
let location = task.location()[diff..].to_string();
format!("...{}", location)
} else {
task.location().to_string()
};

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

let total = task.total(now);

Expand Down

0 comments on commit bba1c6b

Please sign in to comment.