-
Notifications
You must be signed in to change notification settings - Fork 455
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
Visualize CR and LF symbols #465
Comments
I don't remember exactly, but it must be that we do some fancy "the only difference is line-endings" detection to decide whether to show them. Your suggestion is simpler in that we don't have to do that. So it seems like a good idea to me, I'd be happy to merge a PR for this. My only concern is if the ␍ and ␊ symbols have any compat problems (e.g. if Travis or some other popular CI system garbles them, then the old approach seems better to me). |
What do you think of "print dots only for the lines that have differences"? |
So, what we're doing now, but just replace
Changing |
For now, there's a logic that flips between the representations depending on the nature of the diff. As you see, it prints "diff without dots, but with \r\n when only EOL differs", and it prints "diff with dots, but without \r\n when whitespace differs". However, I just thought it might be a nice improvement to print dots only for those lines that have whitespace issues. That would keep code more clear, and it would be easier to spot the difference. |
Code less simple, UI more clear. I think this is an overall improvement.
This seems like bling rather than meat. If it simplifies the code, then it becomes meat. But if we're also adding your whitespace comment above, then it's just bling. And if there's a user using a tool with unicode problems, then they probably don't appreciate the bling. Taking a step back for a minute, our fancy "diff detection" seems neat, but users don't know how it works. We think "oh we're being so helpful we only show X when there's an X problem". But it's totally possible that every day there are a thousand people looking at a Spotless error message who say "well I can see I used the wrong case here, but why isn't it showing me my whitespace anymore? Oh well I'll fix the case." So they fix the case manually, then Spotless says "WRONG! Look at this whitespace problem" so they fix that and then it says "WRONG! Look at this line-ending problem". And the user says "why can't they just show it all to me in the first place!" Code has two stakeholders - builders and users. And they each benefit from simple code - builders are less likely to screw it up, and users are more likely to understand what's happening. My instinct on this is that it's hard to read if every line ends with |
Frankly speaking, dots in diffs make code harder to read for me. |
Sounds like "print dots only for those lines that have whitespace issues." is where we have agreement. |
I see that Spotless does not really support CR-based (== If that is the case, then there's no need to visualize ␊ |
The problem is user-education. If Spotless says |
Running Spotless with
In other words, Spotless should probably refrain from using characters that are not encodable with In other words, there should probably be two styles of "whitespace visualization", and the default one should be selected based on the encoding capabilities. |
context lines, added-only lines, and removed-only lines are shown as usual in the diffs. fixes diffplug#465
context lines, added-only lines, and removed-only lines are shown as usual in the diffs. fixes diffplug#465
context lines, added-only lines, and removed-only lines are shown as usual in the diffs. fixes diffplug#465
context lines, added-only lines, and removed-only lines are shown as usual in the diffs. fixes diffplug#465
Released in |
Migrated to autostyle/autostyle#2 |
CR and LF are invisible in Spotless output.
For instance:
So far so good. Spotless shows that
\n
should not be there (which is true because I'm on macOS, and lines should end with LF).However, if I add one more line with "trailing whitespace", then the output becomes
Note:
x=2
still has the wrong line ending, however, spotless does not print a warning on that.spotlessApply
corrects both issues (newline and the trailing whitespace).Have you considered to use unicode characters like
SYMBOL FOR CARRIAGE RETURN, ␍
SYMBOL FOR LINE FEED, ␊
?
Then the output could be like
The text was updated successfully, but these errors were encountered: