Line Seperator issue between windows and unix
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 35/100
Piste de recherche
Reproduisez la divergence à l’aide de google-java-format-1.10.0-all-deps.jar et de l’exemple MinimalExample.java avec des fins de ligne LF et CRLF. Suivez la raison pour laquelle le formateur produit des retours à la ligne différents, puis vérifiez que le formatage du même code source produit une sortie cohérente sans saut de ligne supplémentaire sur les deux plateformes.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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)
- Langage dominant
- Java
- Étoiles
- 6.2k
- Forks
- 936
- Merge moyen
- 6 min
- PR mergées (30 j)
- 3
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de google/google-java-format
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
google/google-java-format#1094 · 1 commentaire ·
-
Complementary Teamups Ouverte
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 15/100
google/google-java-format#1450 · 1 réaction ·
-
Difficulté 4/5 3-5 jours Accessibilité débutants 55/100
google/google-java-format#1439 · 1 commentaire ·
-
Difficulté 3/5 1-2 jours Accessibilité débutants 62/100
google/google-java-format#1436 · 2 commentaires ·
-
Difficulté 3/5 1-2 jours Accessibilité débutants 48/100
google/google-java-format#1428 · 4 commentaires ·
Toutes les issues de google/google-java-format
Issues similaires
-
executions.Query — startDate and timeRange filters are sent with inverted comparison operators Ouvertearea/plugin
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
kestra-io/plugin-kestra#190 ·
-
litertlm-android AAR ships no consumer ProGuard rules → "mid == null" SIGABRT in minified apps Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
google-ai-edge/LiteRT-LM#3739 ·
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
-
Add canonical URLs and a sitemap Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
integra-team-red/meet-map#249 ·
-
[Studio][Bug] Cancelled create-user dialog keeps the password and admin switch for the next attempt Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
apache/rocketmq-dashboard#5064 ·