Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij code style to align single-line comments

Right now IntelliJ's autoformat changes this:

    val reduceFn = (left: U, right: U) => {
      left ++ right                         // comment 1
              .myFuncA( _._1 )              // comment 2
              .myFuncABC {                  // comment 3
                g => {                      // comment 4
                  g.myFun                   
                  ._2                       
                  .myFunBBB( 0 )( _ + _ )   
                }
              }
    }: U                                    // comment 5

to this:

    val reduceFn = (left: U, right: U) => {
      left ++ right // comment 1
              .myFuncA( _._1 ) // comment 2
              .myFuncABC {
                // comment 3
                g => {
                  // comment 4
                  g.myFun 
                  ._2 
                  .myFunBBB( 0 )( _ + _ ) 
                }
              }
    }: U // comment 5

Is there a way I can tell IntelliJ to produce, or, at the very least, not clobber the former style? I don't see comments as an option in Code Style in Editor > Code Style > Scala:

enter image description here

like image 323
Myer Avatar asked Mar 28 '15 15:03

Myer


1 Answers

Unfortunately, I don't think this is supported at the moment. There's a ticket for it (SCL-4269), but as of writing there has not been any real activity on it.

You can completely disable the formatter for certain lines by using the formatter control option (cf. Code Style preference page). But that's obviously not a good solution.

like image 176
morsch Avatar answered Sep 21 '22 17:09

morsch