Skip to content

Commit

Permalink
fix(console): make long locations readable
Browse files Browse the repository at this point in the history
This closes #411.
  • Loading branch information
guerinoni committed Jul 3, 2023
1 parent 2de5b68 commit f9378b2
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions tokio-console/src/view/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,17 @@ 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() + 4; // NOTE: 4 is margin for keep visibile line+column numbers at the end.
let location = 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();
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 f9378b2

Please sign in to comment.