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

--color=debug: combine segments with same labels #4067

Merged
merged 2 commits into from
Jul 11, 2024

Conversation

jonathantanmy
Copy link
Collaborator

I noticed this when doing the diff whitespace work.

(notice the repeated "diff removed line_number" labels) From

[38;5;1m<<diff removed line_number:: >><<diff removed line_number:: >><<diff removed line_number:: >><<diff removed line_number::1>>[39m<<diff:: >><<diff::    : >>[4m[38;5;1m<<diff removed token::foo>>[24m[39m

to

[38;5;1m<<diff removed line_number::   1>>[39m<<diff::     : >>[4m[38;5;1m<<diff removed token::foo>>[24m[39m

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, demos/)
  • I have updated the config schema (cli/src/config-schema.json)
  • I have added tests to cover my changes

This makes the debug output cleaner and makes the subsequent commit
easier to write.
@ilyagr
Copy link
Collaborator

ilyagr commented Jul 11, 2024

We discussed this idea with @yuja previously, and he was leaning against it.

However, I still like the idea, since it's so nice to have readable tests. Yuya, if you still would like to have the debug mode to report precisely what happened, would you perhaps be OK with having a separate debug mode for more readable output?

Copy link
Collaborator

@yuja yuja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't wanna introduce complexity in debug code, which was the main motivation to not deduplicate label outputs. I think this implementation is simple enough to get in. Thanks.

cli/src/formatter.rs Outdated Show resolved Hide resolved
cli/src/formatter.rs Outdated Show resolved Hide resolved
This not only makes the output easier to read, but also protects against
implementation detail changes in `write!` when used with a format
string (especially, how many times and with what strings it calls the
underlying writer).
@jonathantanmy jonathantanmy force-pushed the jt/cleanercolordebug branch from b6a199a to 2b8383b Compare July 11, 2024 17:15
@jonathantanmy jonathantanmy merged commit de2940f into main Jul 11, 2024
29 checks passed
@jonathantanmy jonathantanmy deleted the jt/cleanercolordebug branch July 11, 2024 17:39
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.

3 participants