redhat-developer / redhat-developer/vscode-java

Formatter changes/deletes my code

未关闭
#1,132 15 条评论 2 个 reaction 已指派 1 人 在 GitHub 查看

@snjeza 已经在做这个了。

开始于 2020年11月3日。

bug formatter
主要语言
TypeScript
星标
2.3k
派生
546
平均合并
20 小时 1 分钟
30 天内合并 PR
11

描述

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?

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。