Skip to content

Commit edaeccb

Browse files
committed
feat(console): left-align task IDs
This looks somewhat nicer, IMO --- and, `top` and `htop` do this. It would be nice to also left-align other numeric values (a la `top`/`htop`), but we can't do that for `Duration`s currently, as the `fmt::Debug` impl for `std::time::Duration` simply ignores alignment specifiers (see rust-lang/rust#88059). We could write our own custom formatter for durations, I guess...
1 parent 92a1ea5 commit edaeccb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

console/src/view/tasks.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,11 @@ impl List {
110110
let task = task.borrow();
111111
let is_terminated = task.completed_for() > 0;
112112
let mut row = Row::new(vec![
113-
Cell::from(id_width.update_str(task.id().to_string())),
113+
Cell::from(id_width.update_str(format!(
114+
"{:>width$}",
115+
task.id(),
116+
width = id_width.chars() as usize
117+
))),
114118
Cell::from(task.state().render(styles)),
115119
dur_cell(task.total(now)),
116120
dur_cell(task.busy(now)),

0 commit comments

Comments
 (0)