Line Seperator issue between windows and unix
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
Direzione di ricerca
Riproduci la discrepanza usando google-java-format-1.10.0-all-deps.jar e l’esempio MinimalExample.java con terminatori di riga LF e CRLF. Traccia il motivo per cui il formattatore produce una disposizione delle righe diversa, quindi verifica che la formattazione della stessa sorgente produca un output coerente senza un’interruzione di riga aggiuntiva su entrambe le piattaforme.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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)
- Lingua principale
- Java
- Stelle
- 6.2k
- Fork
- 936
- Merge medio
- 6m
- PR unite (30g)
- 3
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di google/google-java-format
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
google/google-java-format#1094 · 1 commento ·
-
Complementary Teamups Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 15/100
google/google-java-format#1450 · 1 reazione ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
google/google-java-format#1439 · 1 commento ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 62/100
google/google-java-format#1436 · 2 commenti ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
google/google-java-format#1428 · 4 commenti ·
Tutte le issue di google/google-java-format
Issue simili
-
executions.Query — startDate and timeRange filters are sent with inverted comparison operators Apertaarea/plugin
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
kestra-io/plugin-kestra#190 ·
-
litertlm-android AAR ships no consumer ProGuard rules → "mid == null" SIGABRT in minified apps Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
google-ai-edge/LiteRT-LM#3739 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
integra-team-red/meet-map#249 ·
-
[Studio][Bug] Cancelled create-user dialog keeps the password and admin switch for the next attempt Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
apache/rocketmq-dashboard#5064 ·
-
Consent portal: creating a duplicate Purpose shows a generic error instead of "already exists" Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
wso2/dpdp-accelerator#287 ·