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

Single arg breaking #160

Closed
sjrd opened this issue Apr 14, 2016 · 2 comments
Closed

Single arg breaking #160

sjrd opened this issue Apr 14, 2016 · 2 comments

Comments

@sjrd
Copy link

sjrd commented Apr 14, 2016

Original:

   implicit class IterableW[+A](it: JSIterable[A]) {
     def iterator(): Iterator[A] =
-      toIterator(it.asInstanceOf[IteratorMethodAccess].bracketCall[JSIterator[A]](iteratorSy
+      toIterator(it
+            .asInstanceOf[IteratorMethodAccess]
+            .bracketCall[JSIterator[A]](iteratorSymbol)())
   }

Scalafmt:

OUTPUT FROM SCALAFMT

I would like the input to look like this:

HOW YOU WANT THE OUTPUT TO LOOK LIKE.

Using

  • 0.1.x
@olafurpg
Copy link
Member

olafurpg commented Apr 16, 2016

I have a working implementation that produces this output:

implicit class IterableW[+A](it: JSIterable[A]) {
  def iterator(): Iterator[A] =
   toIterator(
       it.asInstanceOf[IteratorMethodAccess]
         .bracketCall[JSIterator[A]](iteratorSymbol)())
}

What do you think @sjrd?

These changes were twofold and will impact (positively, IMO) current scalafmt users:

  • Newlines inside applications are slightly more penalised if there's no space after opening ( compared to putting a newline after (. This was necessary to move the it to a new line. One unit test that was affected:
// before 
object a {
  function(function(function(a, b),
                    function(c, d)))
}

// after 
object a {
  function(
      function(function(a, b),
               function(c, d)))
}
  • We don't put a newline before the first dot . if it the indentation exceeds the current column. This prevents funny output like:
// before
a
  .fooo(bar)
  .kaz(mania)

// after
a.fooo(bar)
  .kaz(mania)

@sjrd
Copy link
Author

sjrd commented Apr 16, 2016

That sounds reasonable.

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

No branches or pull requests

2 participants