question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Visualize CR and LF symbols

See original GitHub issue

CR and LF are invisible in Spotless output.

For instance:

      src/core/src/main/java/org/apache/jmeter/SplashScreen.java
          @@ -52,7 +52,7 @@
                   setLocationRelativeTo(null);\n
               }\n
           \n
          -    private int x=2;\r\n
          +    private int x=2;\n
           \n
               /**\n
                * Show screen\n

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

      src/core/src/main/java/org/apache/jmeter/SplashScreen.java
          @@ -53,7 +53,7 @@
           ····}

           ·····private·int·x=2;
          -·····private·int·y=3;··
          +·····private·int·y=3;

           ····/**
           ·····*·Show·screen

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

      src/core/src/main/java/org/apache/jmeter/SplashScreen.java
          @@ -53,7 +53,7 @@
           ····}

          -·····private·int·x=2;␍␊
          -·····private·int·y=3;··␊
          -·····private·int·x=2;␊
          +·····private·int·y=3;␊

           ····/**
           ·····*·Show·screen

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
vlsicommented, Nov 5, 2019

Running Spotless with file.encoding=ISO-8859-1 produces something like

17:01:43            �*���http://www.apache.org/licenses/LICENSE-2.0
17:01:43            �*
17:01:43            �*�Unless�required�by�applicable�law�or�agreed�to�in�writing,�software
17:01:43           -�*�distributed��under�the��License�is�distributed�on�an�"AS�IS"�BASIS,
17:01:43           -�*�WITHOUT��WARRANTIES�OR�CONDITIONS��OF�ANY�KIND,�either��express��or
17:01:43           -�*�implied.
17:01:43           -�*
17:01:43           +�*�distributed�under�the�License�is�distributed�on�an�"AS�IS"�BASIS,
17:01:43           +�*�WITHOUT�WARRANTIES�OR�CONDITIONS�OF�ANY�KIND,�either�express�or�implied.
17:01:43            �*�See�the�License�for�the�specific�language�governing�permissions�and
17:01:43            �*�limitations�under�the�License.
17:01:43           +�*

In other words, Spotless should probably refrain from using characters that are not encodable with file.encoding.

In other words, there should probably be two styles of “whitespace visualization”, and the default one should be selected based on the encoding capabilities.

0reactions
vlsicommented, Nov 12, 2019
Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I visualize CR LF in WORD? - Super User
Visual symbols for Carriage-Return and Line-Feed. For exactly this purpose, there are Unicode control pictures for CR and LF
Read more >
Visualize CR and LF symbols · Issue #465 · diffplug/spotless
CR and LF are invisible in Spotless output. For instance: src/core/src/main/java/org/apache/jmeter/SplashScreen.java @@ -52, ...
Read more >
How to properly format your logo carriage return (CR LF to LF)
In Notepad++ go to the View > Show Symbol menu and select Show End of Line. Once you select View > Show Symbol...
Read more >
How do I show/hide the "CR" and "LF" text at the end of the ...
From the edit point to the end of the file now shows the CR LF symbols in reverse (black rounded corner boxes with...
Read more >
CRLF - MDN Web Docs Glossary: Definitions of Web-related ...
CR and LF are control characters or bytecode that can be used to mark a line break in a text file.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found