Skip to content
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

Append final newline in read_line_initial_text #113

Merged
merged 1 commit into from
Feb 11, 2022

Conversation

RichRandall
Copy link
Contributor

@RichRandall RichRandall commented Jan 25, 2022

Proposed fix for issue 112

Note that this changes the behaviour of Term::read_line_initial_text() to make it consistent with Term:read_line(). No change to the return value, but a change in side effects.

dtolnay pushed a commit to dtolnay-contrib/console that referenced this pull request Feb 4, 2022
Depends on console-rs#112

This branch builds on console-rs#112 by calculating the *percentage* of a task's
wakeups that were self-wakes, and displaying them in the tasks view. It
also adds the beginnings of a rudimentary "Warnings" system, and
displays warnings for any tasks who have woken themselves for more than
50% of their wakeups. There is a new `Warn` trait for generating
warnings that can be used to add new warnings in the future.

The warnings functionality can almost certainly be expanded --- for
example, it would be nice to be able to quickly jump to the details view
for a task that has warnings. In the future, I could imagine generating web
documentation with details about a particular warning and how to fix it,
like [clippy has][1], and linking to them from the console. But, this is a start,
at least!

[1]: https://rust-lang.github.io/rust-clippy/v0.0.174/
![image](https://user-images.githubusercontent.com/2796466/132146062-9599ba12-cb17-48f8-b15c-4ba91947e282.png)
![image](https://user-images.githubusercontent.com/2796466/132146081-6dac231c-e929-4f93-b6ef-ac16f1dd166d.png)

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
dtolnay pushed a commit to dtolnay-contrib/console that referenced this pull request Feb 4, 2022
…s#123)

The current method of displaying warnings is as list of all individual
tasks with warnings on the task list screen. As discussed in the
comments on PR console-rs#113, this may not be the ideal approach when there are a
very large number of tasks with warnings.

This branch changes this behavior so that the details of a particular
warning for a given task is shown only on the task details screen. On
the task list screen, we instead list the different _categories_ of
warnings that were detected, along with the number of tasks with that
warning. This means that when a large number of tasks have warnings, we
will only use a number of lines equal to the number of different
categories of warning that were detected, rather than the number of
individual tasks that have that warning.

Each individual task that has warnings shows a warning icon and count in
a new column in the task list table. This makes it easy for the user to
find the tasks that have warnings and get details on them, including
sorting by the number of warnings.

Implementing this required some refactoring of how warnings are
implemented. This includes:

* Changing the `Warn` trait to have separate methods for detecting a
  warning, formatting the warning for an individual task instance, and
  summarizing the warning for the list of detected warning types
* Introducing a new `Linter` struct that wraps a `dyn Warning` in an
  `Rc` and clones it into tasks that have lints. This allows the task
  details screen to determine how to format the lint when it is needed.
  It also allows tracking the total number of tasks that have a given
  warning, by using the `Rc`'s reference count.

## Screenshots

To demonstrate how this design saves screen real estate when there are
many tasks with warnings, I modified the `burn` example to spawn
several burn tasks rather than just one.

Before, we spent several lines on warnings (one for each task):
![warn_old](https://user-images.githubusercontent.com/2796466/132567589-862d1f82-1b8a-481e-9ce0-fc0798319c8a.png)

After, we only need one line:
![warnings1](https://user-images.githubusercontent.com/2796466/132567656-2c1473fb-22a2-45bb-99b1-c23cce4d86dd.png)

The detailed warning text for the individual tasks are displayed on the
task details view:
![warnings1_details](https://user-images.githubusercontent.com/2796466/132567713-8e1162f4-f989-488b-b347-f8837ba67d65.png)

And, it still looks okay in ASCII-only mode:
![warnings1_ascii-only](https://user-images.githubusercontent.com/2796466/132567772-9d6ed35d-254d-4b9e-bf6e-eef1819c211c.png)
![warnings1_details_ascii-only](https://user-images.githubusercontent.com/2796466/132567783-a88e4730-0a0d-4240-a285-a99bc2ff1047.png)

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
@pksunkara pksunkara merged commit 5484ea9 into console-rs:master Feb 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants