redhat-developer / redhat-developer/vscode-java

Formatter changes/deletes my code

Abierto
#1,132 15 comentarios 2 reacciones 1 asignado Ver en GitHub

@snjeza ya está trabajando en esto.

Desde el 3/11/2020.

bug formatter
Lenguaje dominante
TypeScript
Estrellas
2.3k
Forks
546
Merge medio
20 h 1 min
PR fusionados (30 d)
11

Descripción

I have the following code

class A {
    String get(Client a) {
        return "AC";
    }
}

class B extends A {
    String get(SpecialClient a) {
        return "BS";
    }
}

class C extends B {
} 
    
    
    

    
        
            

        

      
    

    



    

    

I am keeping all the white spaces here in case they could affect the behavior of the formatter.
With the code above, when I try to save in VS Code (I have turned on formatOnSave), the code becomes

class A {
    String get(Client a) {
        return "AC";
    }
}

class B extends A {
    String get(SpecialClient a) {
        return "BS";
    }
}

class C}

            

    
    
    

    

    
        

    

    
        
    

 

         

     

    



      

    
        

or

class A {
    String get(Client a) {
        return "AC";
    }
}

class B extends A {
    String get(SpecialClient a) {
        return "BS";
    }
}


    class
    C extends
    B {
    
    

    
    
    
     

    
    


    
    
        

        
        
     



    

    

Actually, the code changes to something slightly different every time I tried to reproduce this problem.
This is certainly not the first time I encountered this issue, but since I am not a Java developer, I was not quite bothered by this funny bug.

All java-related extensions I installed are Maven for Java, Debugger for Java, Language Support for Java(TM) by Red Hat, Language Extension Pack, and Java Dependency Viewer.

P.S. I didn't quite remember installing the extensions above, it could be the default extensions installed by VS Code when I wrote my first java file there?

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.