Increase the output color of search results#10116
Increase the output color of search results#10116heisen-li wants to merge 9 commits intorust-lang:masterfrom
Conversation
|
r? @Eh2406 (rust-highfive has picked a reviewer for you, use r? to override) |
f9ca13e to
971618e
Compare
|
Why the test task has not passed? I'm still looking for the reason. If anyone knows, feel free to let me know. |
|
thanks. I didn't notice, I was too careless. The failed test now seems to have nothing to do with me or something. |
|
Sorry if I wasn't clear. The tests can't change to check stderr, the code will need to be changed to use stdout. I don't think the I opened #10120 to track the spurious CI error. |
d5e768b to
c322a72
Compare
c322a72 to
8682ec6
Compare
|
Thanks, you are right. Currently there is an output method for stderr, but there is no corresponding method for stdout. As a supplement, I added a corresponding output method for stdout. |
|
We talked about this a bit, and felt like coloring the entire entry in bright green can make it a bit difficult to read and doesn't particularly improve the results. We were thinking maybe it could just highlight the matching terms in a normal green color in a fashion similar to Would you be willing to try that out? It will require a bit more work to figure out a good API for the |
699c337 to
1c8354c
Compare
|
thank you. I have made the latest changes. I haven't figured out how to design test cases. However, I don't see any other commands to test the output color. It seems unnecessary. |
|
Can you post a screenshot or two of what the search results look like? |
| desc_no_query: Vec<&str>, | ||
| query: &str, | ||
| color: Color, | ||
| justified: bool, |
There was a problem hiding this comment.
This is always true right now so does this need to be a parameter?
| pub fn status_stdout_part_green( | ||
| &mut self, | ||
| name_no_query: Vec<&str>, | ||
| desc_no_query: Vec<&str>, |
There was a problem hiding this comment.
Can you document what these arguments are? I can't figure out what these are from the signature/name of the method...
There was a problem hiding this comment.
Added explanation and changed parameter naming.
src/cargo/core/shell.rs
Outdated
|
|
||
| if !desc_no_query.is_empty() { | ||
| let mut count_desc = 0; | ||
| for message in desc_no_query.iter() { |
There was a problem hiding this comment.
This looks to be the same loop as above, so can the code be refactored to avoid this duplication?
There was a problem hiding this comment.
thank you,refactored the code.
|
@ehuss @alexcrichton @Eh2406 Do you mind having a look when you get a chance? I want to know if I am on the right track. Thanks! |
|
Sorry I do not personally have time to shepherd along this PR. |
|
@qiangheisenberg Sorry for the lack of direction, but I don't think this is quite the way I was thinking. The way this is written seems to be highly specific to the needs for the search results. I was expecting something that was a little more generic that could be used by other things in the future. For example, I think the I also want to say that these reviews are taking an outsized amount of time from us. I would appreciate a little more effort on your side to understand how to approach these problems, and to respond to review comments. Alex asked why Finally, I would expect some kind of test to validate the behavior with color. That can be done by using |
This supersedes rust-lang#10116 Fixes rust-lang#9918
feat(search): Highlight search term This supersedes #10116. For the requested colored-output tests, this followed the pattern of the `fix` tests which just detects whether colored output is used or not. The `cache_messages` actually verify the output is colored but that is because it can just compare to a rustc call's output. Getting the colored output correct by hand in a test (with all of the resets) is a bit messy and would be brittle. This was done in an exercise in exploring ways to generalize colored output support in preparation for `cargo-add` doing some colored output as well. I converted all output calls to use this approach, even if coloring wasn't used, for consistency. I considered coloring the overflow message but decided to hold off on that for now (either a warning-yellow or a hint-gray). Fixes #9918
|
I've r+'d #10425, so I'm going to close this. |




close #9918