diff --git a/tokio-console/src/view/task.rs b/tokio-console/src/view/task.rs index 368fc8abc..7d04c0716 100644 --- a/tokio-console/src/view/task.rs +++ b/tokio-console/src/view/task.rs @@ -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() + 1; // NOTE: 1 is for the space after the title. + 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);