Skip to content

Visualize CR and LF symbols #465

@vlsi

Description

@vlsi

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions