You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now we have UNIX, WINDOWS, PLATFORM_NATIVE, and our default GIT_ATTRIBUTES. These are all "content-blind", in that they can declare the line endings are without looking at the content of the file being formatted.
I'm open to merging a new mode PRESERVE which should work as such:
Add a parameter String raw to each of these two methods (this will be **BREAKING** change in /CHANGES.md)
/** Returns the line ending appropriate for the given file. */
StringgetEndingFor(Filefile);
/** Returns true iff this file has unix line endings. */
publicdefaultbooleanisUnix(Filefile) {
Use that string to count the number of \n and \r characters to determine what the correct line ending should be
Some files in the wild will have a mixture of line endings, but preserving that is out-of-scope, we'll pick whichever line ending is more common in the file
Assuming that the \r are always paired up as \r\n, then
return count_n >= 2 * count_r ? "\n" : "\r\n"
for plugin-gradle/CHANGES.md and plugin-maven/CHANGES.md this is just ### Added, not breaking
I think that GIT_ATTRIBUTES is what almost everyone should be using, so I'm not going to build PRESERVE myself, but I'd be happy to merge a PR for it if you want it.
The text was updated successfully, but these errors were encountered:
Right now we have
UNIX
,WINDOWS
,PLATFORM_NATIVE
, and our defaultGIT_ATTRIBUTES
. These are all "content-blind", in that they can declare the line endings are without looking at the content of the file being formatted.I'm open to merging a new mode
PRESERVE
which should work as such:String raw
to each of these two methods (this will be**BREAKING**
change in/CHANGES.md
)spotless/lib/src/main/java/com/diffplug/spotless/LineEnding.java
Lines 126 to 131 in 4600bc3
\n
and\r
characters to determine what the correct line ending should be\r
are always paired up as\r\n
, thenreturn count_n >= 2 * count_r ? "\n" : "\r\n"
plugin-gradle/CHANGES.md
andplugin-maven/CHANGES.md
this is just### Added
, not breakingI think that
GIT_ATTRIBUTES
is what almost everyone should be using, so I'm not going to buildPRESERVE
myself, but I'd be happy to merge a PR for it if you want it.The text was updated successfully, but these errors were encountered: