redhat-developer / redhat-developer/vscode-java

Formatter changes/deletes my code

Đang mở
#1,132 15 bình luận 2 reaction 1 người được giao Xem trên GitHub

@snjeza đang làm issue này rồi.

Từ ngày 3/11/2020.

bug formatter
Ngôn ngữ chính
TypeScript
Star
2.3k
Fork
546
Merge trung bình
20 giờ 1 phút
Pull request đã merge (30 ngày)
11

Mô tả

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?

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.