Git Product home page Git Product logo

Comments (8)

kitbellew avatar kitbellew commented on June 3, 2024

@NColey if your example is correct, then the problem is case class A must be followed by a list of parameters (otherwise it should be a case object). when i tried class A instead, it aligned correctly.

from scalafmt.

NColey avatar NColey commented on June 3, 2024

@kitbellew I'm sorry that was a typo on my end. The issue I'm seeing is specifically with case objects. I have fixed the example.

from scalafmt.

kitbellew avatar kitbellew commented on June 3, 2024

@NColey weird. case object works for me. specifically, i added this:

<<< ONLY #3762
object a {
  case object A extends Something
  case object AAA extends Something
}
>>>
object a {
  case object A   extends Something
  case object AAA extends Something
}

to the end of DefaultWithAlign.stat file and ran FormatTests.

from scalafmt.

kitbellew avatar kitbellew commented on June 3, 2024

are you sure that your example is not just similar to what you specified but in reality is a lot longer? scalafmt no longer allows alignment to overflow maxColumn unless explicitly configured to do this.

from scalafmt.

NColey avatar NColey commented on June 3, 2024

@kitbellew so I created a super minimal reproduction of the issue here if that helps. If you clone that down and run scalafmt with the latest CLI it will remove the alignment from extends in alignment.scala even though it was previously aligned (or at least it does for me with scalafmt 3.7.17 as the cli version).

Re maxColumn -- when I bumped the version from 2.3.2 to 3.7.17 I responded to anything that was flagged as an error (i.e settings being renamed or removed) and that one wasn't flagged as an issue so I left it as is.

That said, if you look at the repo where I have reproduced this issue you can see I tried it with and without adjustments to maxColumn and it still un-aligns case objects on the extends portion. Totally open to something else in that config file being the issue though I have turned a number of settings on and off and can't seem to preserve the alignment that was there in 2.3.2.

from scalafmt.

kitbellew avatar kitbellew commented on June 3, 2024

@NColey extends is no longer owned by Defn.Object but by the Template field within it. so if you remove all your align { ... } customizations, it formats correctly.

from scalafmt.

kitbellew avatar kitbellew commented on June 3, 2024

you should use AST Explorer linked from https://scalameta.org/scalafmt/docs/configuration.html#aligntokens, it will show you tokens and trees.

from scalafmt.

NColey avatar NColey commented on June 3, 2024

OH! Oh wow thank you, that totally was the issue. I appreciate the AST Explorer suggestion as well, thank you so much 🙏 . I'll close this issue now but appreciate your help here.

from scalafmt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.