-
-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Adjust task and waker panel for long names #527
Open
devanbenz
wants to merge
2
commits into
tokio-rs:main
Choose a base branch
from
devanbenz:523_task_long_names
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ use crate::{ | |
help::HelpText, | ||
}, | ||
}; | ||
use ratatui::widgets::Wrap; | ||
use ratatui::{ | ||
layout::{self, Layout}, | ||
text::{Span, Spans, Text}, | ||
|
@@ -131,8 +132,8 @@ impl TaskView { | |
.direction(layout::Direction::Horizontal) | ||
.constraints( | ||
[ | ||
layout::Constraint::Percentage(50), | ||
layout::Constraint::Percentage(50), | ||
layout::Constraint::Percentage(60), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we might want something more dynamic than this. What do you think? |
||
layout::Constraint::Percentage(40), | ||
] | ||
.as_ref(), | ||
) | ||
|
@@ -156,16 +157,8 @@ impl TaskView { | |
])); | ||
|
||
let title = "Location: "; | ||
let location_max_width = stats_area[0].width as usize - 2 - title.len(); // NOTE: -2 for the border | ||
let location = if task.location().len() > location_max_width { | ||
let ellipsis = styles.if_utf8("\u{2026}", "..."); | ||
let start = task.location().len() - location_max_width + ellipsis.chars().count(); | ||
format!("{}{}", ellipsis, &task.location()[start..]) | ||
} else { | ||
task.location().to_string() | ||
}; | ||
|
||
overview.push(Spans::from(vec![bold(title), Span::raw(location)])); | ||
overview.push(Spans::from(vec![bold(title), Span::raw(task.location())])); | ||
|
||
let total = task.total(now); | ||
|
||
|
@@ -195,21 +188,21 @@ impl TaskView { | |
Span::from(format!("{})", task.waker_drops())), | ||
])]; | ||
|
||
let mut wakeups = vec![ | ||
let wakeups = vec![ | ||
bold("Woken: "), | ||
Span::from(format!("{} times", task.wakes())), | ||
]; | ||
|
||
waker_stats.push(Spans::from(wakeups)); | ||
|
||
// If the task has been woken, add the time since wake to its stats as well. | ||
if let Some(since) = task.since_wake(now) { | ||
wakeups.reserve(3); | ||
wakeups.push(Span::raw(", ")); | ||
wakeups.push(bold("last woken:")); | ||
wakeups.push(Span::from(format!(" {:?} ago", since))); | ||
waker_stats.push(Spans::from(vec![ | ||
bold("Last woken:"), | ||
Span::from(format!(" {:?} ago", since)), | ||
])); | ||
} | ||
|
||
waker_stats.push(Spans::from(wakeups)); | ||
|
||
if task.self_wakes() > 0 { | ||
waker_stats.push(Spans::from(vec![ | ||
bold("Self Wakes: "), | ||
|
@@ -229,7 +222,9 @@ impl TaskView { | |
frame.render_widget(warnings, warnings_area); | ||
} | ||
|
||
let task_widget = Paragraph::new(overview).block(styles.border_block().title("Task")); | ||
let task_widget = Paragraph::new(overview) | ||
.wrap(Wrap { trim: true }) | ||
.block(styles.border_block().title("Task")); | ||
let wakers_widget = Paragraph::new(waker_stats).block(styles.border_block().title("Waker")); | ||
|
||
let poll_percentiles_title = "Poll Times Percentiles"; | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: merge this with the other ratatui imports ok the next line.