Line Seperator issue between windows and unix
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 35/100
Rechercherichtung
Reproduziere die Abweichung mit google-java-format-1.10.0-all-deps.jar und dem Beispiel MinimalExample.java mit sowohl LF- als auch CRLF-Zeilenenden. Verfolge, warum der Formatter unterschiedliche Umbrüche erzeugt, und überprüfe anschließend, dass das Formatieren derselben Quelle auf beiden Plattformen eine konsistente Ausgabe ohne zusätzlichen Zeilenumbruch liefert.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
When applying GJF, some code is formatted differently between Unix-style line seperators (LF) and Windows-style line seperators (CRLF). With windows-style an extra linebreak is added, caused by the char difference between LF (\n) and CRLF (\r\n).
I changed the line-separator-style with Intellij (File>File Properties> Line Separators, while having the file opened) and got the following outputs:
Executing java -jar google-java-format-1.10.0-all-deps.jar MinimalExample.java when the file is formatted with Unix line endings:
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import feign.FeignException;
public class MinimalExample {
void googleJavaFormatWindowsFail() {
FeignException feignException = mock(FeignException.class);
when(feignException.contentUTF8()).thenReturn("""
{
"errorCode" : 420
}
""");
}
}
Executing java -jar google-java-format-1.10.0-all-deps.jar MinimalExample.java when the file is formatted with Windows line endings:
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import feign.FeignException;
public class MinimalExample {
void googleJavaFormatWindowsFail() {
FeignException feignException = mock(FeignException.class);
when(feignException.contentUTF8())
.thenReturn("""
{
"errorCode" : 420
}
""");
}
}
If two chars are added, Unix-style generates the same line-break:
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import feign.FeignException;
public class MinimalExample {
void googleJavaFormatWindowsFail() {
FeignException feignException = mock(FeignException.class);
when(feignException.contentUTF8())
.thenReturn("""
{
"errorCode" : 42069
}
""");
}
}
Done on GJF 1.10.0, 1,9 and 1.8 with Java 15.0.2
Windows 10 10.0
IntelliJ IDEA 2021.1.1 (Community Edition)
- Vorherrschende Sprache
- Java
- Sterne
- 6.2k
- Forks
- 936
- Ø Merge
- 6 Min.
- Gemergte PRs (30 T.)
- 3
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus google/google-java-format
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
google/google-java-format#1094 · 1 Kommentar ·
-
Complementary Teamups Offen
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 15/100
google/google-java-format#1450 · 1 Reaktion ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 55/100
google/google-java-format#1439 · 1 Kommentar ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 62/100
google/google-java-format#1436 · 2 Kommentare ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 48/100
google/google-java-format#1428 · 4 Kommentare ·
Alle Issues in google/google-java-format
Ähnliche Issues
-
executions.Query — startDate and timeRange filters are sent with inverted comparison operators Offenarea/plugin
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
kestra-io/plugin-kestra#190 ·
-
litertlm-android AAR ships no consumer ProGuard rules → "mid == null" SIGABRT in minified apps Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
google-ai-edge/LiteRT-LM#3739 ·
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
integra-team-red/meet-map#249 ·
-
[Studio][Bug] Cancelled create-user dialog keeps the password and admin switch for the next attempt Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
apache/rocketmq-dashboard#5064 ·