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

Keep the breaking in new lines #366

Closed
joan38 opened this issue Jul 7, 2016 · 8 comments
Closed

Keep the breaking in new lines #366

joan38 opened this issue Jul 7, 2016 · 8 comments

Comments

@joan38
Copy link
Contributor

joan38 commented Jul 7, 2016

Hi,

Original:

execute(request)
     .map(success => Xor.Right(success))
     .recover { case failure: Throwable => Xor.Left(failure) }

Scalafmt:

execute(request).map(success => Xor.Right(success)).recover { case failure: Throwable => Xor.Left(failure)

I would like Scalafmt to keep the breaking in new lines.

Using:

  • 0.2.10
  • --maxColumn 120

Thanks!

@olafurpg
Copy link
Member

I have also experienced that scalafmt forces a select chain on a single line when I would like it to be multiline. It would be possible to skip the single line layout if there is a newline before the first select, which is .map(...) in this case. Scalafmt already does similar things for bodies of defs.

@olafurpg
Copy link
Member

I think this can be fixed here: https://github.com/olafurpg/scalafmt/blob/master/core/src/main/scala/org/scalafmt/internal/Router.scala#L828

It should be something like Split(NoSplit, 0, ignoreIf = newlines > 0). However, I would like to keep the default behavior the way it is, so you need to guard against some setting like style.keepSelectChainLineBreaks. The setting doesn't exist yet so that needs to be added to ScalafmtStyle and Cli.

@melrief
Copy link
Contributor

melrief commented Sep 11, 2016

Pushed a PR that solves this.

@olafurpg
Copy link
Member

Closed in #440

@joan38
Copy link
Contributor Author

joan38 commented Sep 28, 2016

I don't quiet understand how to use this.
I tried:

keepSelectChainLineBreaks = true

and

breakChainOnFirstMethodDot = true

@olafurpg
Copy link
Member

@olafurpg
Copy link
Member

There's a section in the changelog describing more about the flag

@joan38
Copy link
Contributor Author

joan38 commented Sep 28, 2016

Thanks @olafurpg for the hint!

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

No branches or pull requests

3 participants