Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wired alignment when chain contains comment / no parenthesis call / with parenthesis call #1334

Closed
lxohi opened this issue Jan 4, 2019 · 3 comments · Fixed by #2067
Closed
Labels

Comments

@lxohi
Copy link

lxohi commented Jan 4, 2019

  • Version: 1.5.1 (scalafmt plugin version)
  • Integration: IntelliJ
  • Configuration:
maxColumn = 150
docstrings = JavaDoc
align = none

Steps

Given code like this:

class Foo {
  val vv = v.aaa //
    .aaa
    .bbb()
}

When I run scalafmt like this:

<press Reformat with scalafmt key>

Problem

Scalafmt formats code like this:

class Foo {
  val vv = v.aaa //
  .aaa
    .bbb()
}

Expectation

I would like the formatted output to look like this:

class Foo {
  val vv = v.aaa //
    .aaa
    .bbb()
}

Or like this:

class Foo {
  val vv = v
    .aaa //
    .aaa
    .bbb()
}

Notes

I found a config key includeNoParensInSelectChains in the document may related with this issue.
But after I added this key to my conf, intellij IDEA reports:

12:33	Scalafmt
			Failed to read /................/.scalafmt.conf. 
			Invalid fields: includeNoParensInSelectChains

Meanwhile the Show original / Show formatted button in the document for this config key was not functional either at this time.

@lxohi lxohi changed the title Wired alignment when chains contains comment / no parenthesis call / with parenthesis call Wired alignment when chain contains comment / no parenthesis call / with parenthesis call Jan 4, 2019
@lxohi
Copy link
Author

lxohi commented Jan 4, 2019

I've tried nightly version 1.6.0-RC4. This behavior was the same.

@TaranTheMonk
Copy link

this problem also happened from my side, if my .scalafmt.conf file has includeNoParensInSelectChains=True, the IDE(intellij) will failed on reading it.

@poslegm poslegm added the bug label Nov 8, 2019
kitbellew pushed a commit to kitbellew/scalafmt that referenced this issue Nov 20, 2019
kitbellew pushed a commit to kitbellew/scalafmt that referenced this issue Nov 20, 2019
kitbellew pushed a commit to kitbellew/scalafmt that referenced this issue Nov 24, 2019
Currently, the code doesn't introduce newlines into select chains even
if their length exceeds the maximum line length.

It also results in missing indent when a comment is in the middle of
such a chain.

Fix both problems, by allowing a newline if one is present in the input.

Fixes scalameta#1334.
@kitbellew
Copy link
Collaborator

@lxohi this was fixed when using newlines.source (you can use keep although i'd suggest trying one of the other two modes). i do not think i will fix it for the classic mode, the select-chain rule in that case is too complex.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants