How to wrap Scala Infix expressions within long lines in IntellijIDEA?

77 Views Asked by At

I am using the .editorconfig file in order to configure my IntellijIDEA IDE to reformat Scala code in a specific way.

I specified a right margin, and specified for it not to be exceeded, however, this has a bad impact on long lines that have an Infix expression, which breaks the code. Everything else is reformatted correctly.

Specific editorconfig configuration :

max_line_length = 100
ij_scala_call_parameters_wrap = normal
ij_scala_method_call_chain_wrap = normal
ij_scala_variable_annotation_wrap = normal
ij_scala_wrap_long_lines = true

The line i am trying to reformat :

  override val fooBarJognDoeLongVar: List[fooBarJognDoeLongVarType] = DoThisDoThat() :: DoThisDoThatAgain() :: DoThisDoThatAgainOneMoreTime() :: DoThisDoThatAgainOneMoreTimeOnceAgain() :: Nil

When it's reformatted, it looks like this :

  override val fooBarJognDoeLongVar: List[fooBarJognDoeLongVarType] = DoThisDoThat() :: DoThisDoThatAgain() :: DoThisDoThatAgainOneMoreTime() 
  :: DoThisDoThatAgainOneMoreTimeOnceAgain() :: Nil

And that breaks the expression apparently. This line should be broken like this :

  override val fooBarJognDoeLongVar: List[fooBarJognDoeLongVarType] = DoThisDoThat() :: DoThisDoThatAgain() :: DoThisDoThatAgainOneMoreTime() ::
  DoThisDoThatAgainOneMoreTimeOnceAgain() :: Nil

With the :: kept on the first line, before the line return.

Any ideas on how to do this please ? Of course, using the editorconfig file.

0

There are 0 best solutions below