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

Align lines with different columns count #1785

Merged
merged 3 commits into from
Mar 16, 2020

Conversation

poslegm
Copy link
Collaborator

@poslegm poslegm commented Mar 15, 2020

Fixes #1783

TL;DR

//before
libraryDependencies ++= Seq(
  "a"   % "x" %% "1",
  "b" %%% "y"  % "2.2.2.2" % Test,
  "c"  %% "z"  % "3" % Test
)
//after
libraryDependencies ++= Seq(
  "a"   % "x" %% "1",
  "b" %%% "y"  % "2.2.2.2" % Test,
  "c"  %% "z"  % "3"       % Test
)

For pretty `% Test` block formatting:

```
libraryDependencies ++= Seq(
  "io.get-coursier"       % "interface"      %% "0.0.17",
  "com.geirsson1111111" %%% "metaconfig-core" % metaconfigV % Test,
  "org.scalacheck"       %% "scalacheck"      % sclacheckV  % Test
)
```
@@ -663,7 +663,7 @@ class FormatWriter(formatOps: FormatOps) {
val units = Vector.newBuilder[AlignmentUnit]
while (i < block.length) {
val line = block(i)
if (line.lengthCompare(column) == 1) {
if (column < line.length) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, if you like lengthCompare, line.lengthCompare(column) > 0, although not necessarily more readable :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I originally wrote lengthCompare I overlooked that line is Array. So lengthCompare is redundant optimization here :)

@poslegm
Copy link
Collaborator Author

poslegm commented Mar 15, 2020

@kitbellew Also when running this changes on scala-repos I discovered idempotency violations on master:

scala-repos diff: poslegm/scala-repos@4554a0a

broken example:

<<< ONLY step 1
private def getTopN[T](s: Iterable[T], n: Int)(
      implicit ord: Ordering[T]): Seq[T]
>>>
private def getTopN[T](s: Iterable[T], n: Int)(
    implicit ord: Ordering[T]	   
): Seq[T]
<<< ONLY step 2
private def getTopN[T](s: Iterable[T], n: Int)(
    implicit ord: Ordering[T]	   
): Seq[T]
>>>
private def getTopN[T](s: Iterable[T], n: Int)(implicit
    ord: Ordering[T]
): Seq[T]

(works correct at 2.4.2)

Is it related to your latest changes?

@kitbellew
Copy link
Collaborator

@kitbellew Also when running this changes on scala-repos I discovered idempotency violations on master:

scala-repos diff: poslegm/scala-repos@4554a0a

broken example:

<<< ONLY step 1
private def getTopN[T](s: Iterable[T], n: Int)(
      implicit ord: Ordering[T]): Seq[T]
>>>
private def getTopN[T](s: Iterable[T], n: Int)(
    implicit ord: Ordering[T]	   
): Seq[T]
<<< ONLY step 2
private def getTopN[T](s: Iterable[T], n: Int)(
    implicit ord: Ordering[T]	   
): Seq[T]
>>>
private def getTopN[T](s: Iterable[T], n: Int)(implicit
    ord: Ordering[T]
): Seq[T]

(works correct at 2.4.2)

Is it related to your latest changes?

probably :( implicit handling is new. can you disable them for now, open a ticket for me to track, please?

@poslegm
Copy link
Collaborator Author

poslegm commented Mar 16, 2020

#1787

@poslegm poslegm merged commit 21bc794 into scalameta:master Mar 16, 2020
@poslegm poslegm deleted the alignment-blocks-fix branch March 16, 2020 01:20
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 this pull request may close these issues.

Align lines with different columns count
2 participants