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

Separated defns get aligned since 3.0.5 #2775

Closed
yurique opened this issue Sep 27, 2021 · 3 comments · Fixed by #2778
Closed

Separated defns get aligned since 3.0.5 #2775

yurique opened this issue Sep 27, 2021 · 3 comments · Fixed by #2778

Comments

@yurique
Copy link

yurique commented Sep 27, 2021

  • Version: 3.0.5
  • Configuration:
version=3.0.5
runner.dialect = "scala213"
fileOverride {
  "glob:**/scala-3/**" {
    runner.dialect = scala3
  }
}
style = defaultWithAlign
align.openParenCallSite = true
align.openParenDefnSite = true
align.arrowEnumeratorGenerator = true
maxColumn = 160
continuationIndent.defnSite = 2
assumeStandardLibraryStripMargin = true
danglingParentheses.defnSite = true
danglingParentheses.callSite = true
rewrite.rules = [AvoidInfix, ExpandImportSelectors, RedundantParens, SortModifiers]
docstrings = JavaDoc
newlines.afterCurlyLambda = preserve
docstrings.style = Asterisk
docstrings.oneline = unfold
trailingCommas = "preserve"
optIn.breaksInsideChains = true
includeCurlyBraceInSelectChains = true
//includeNoParensInSelectChains = true
binPack.parentConstructors="never"
//newlines.source="keep"
align.preset = most

Steps

Update scalafmt version from 3.0.4 to 3.0.5.

Example:
https://github.com/tulz-app/laminext/pull/72/files

Given code like this:

  override protected[this] def onStart(): Unit = {
    startCallback()
    super.onStart()
  }

  override protected[this] def onStop(): Unit = {
    stopCallback()
    super.onStop()
  }

When I run scalafmt like this:

via the sbt-scalafmt plugin.

Problem

Scalafmt formats code like this (there are more defs in the file, so the = got aligned with the furthest one):

  override protected[this] def onStart(): Unit                                         = {
    startCallback()
    super.onStart()
  }

  override protected[this] def onStop(): Unit                                          = {
    stopCallback()
    super.onStop()
  }

Expectation

I would like the formatted output to look like this (same as original, as it was already correctly formatted with 3.0.4):

  override protected[this] def onStart(): Unit = {
    startCallback()
    super.onStart()
  }

  override protected[this] def onStop(): Unit = {
    stopCallback()
    super.onStop()
  }

Notes

This might be related to this PR: #2753

@github-dimitri-ho
Copy link

It seems to happen only when one of the methods in the object / class has a scope modifier

@yurique
Copy link
Author

yurique commented Sep 27, 2021

in the same example PR, same formatting got applied to the lazy vals in the build.sbt: https://github.com/tulz-app/laminext/pull/72/files#diff-5634c415cd8c8504fdb973a3ed092300b43c4b8fc1e184f7249eb29a55511f91

@poslegm
Copy link
Collaborator

poslegm commented Sep 27, 2021

Another example: poslegm/munit-zio@50387ef

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

Successfully merging a pull request may close this issue.

3 participants