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

Investigate forcing multi line parameters onto newline #7

Closed
daniel-trinh opened this issue Feb 5, 2014 · 2 comments
Closed

Investigate forcing multi line parameters onto newline #7

daniel-trinh opened this issue Feb 5, 2014 · 2 comments

Comments

@daniel-trinh
Copy link
Owner

Currently, this

def something(a: Int,
  b: String, 
  c: Boolean)(d: Int,
  e: String, 
  f: Boolean)

is reformatted to this

def something(a: Int,
              b: String, 
              c: Boolean)(d: Int,
                          e: String, 
                          f: Boolean)

It would be simpler to just have it force the parameter onto a newline:

def something(
  a: Int,
  b: String, 
  c: Boolean)(
    d: Int,
    e: String, 
    f: Boolean)

or

def something(
  a: Int,
  b: String, 
  c: Boolean)(
  d: Int,
  e: String, 
  f: Boolean)

Reasoning for this: The "force to newline" version is already valid Scalariform formatting, which will occur if the user places the first parameter on a newline themselves. It'd be simpler to maintain the formatting code if only one of these versions were supported, and would be easier for people to read / get used to, since multi line arguments would always be formatted in the same way.

@bambuchaAdm
Copy link

I think after merging #4 after first parameter there will be insert newline so example

def something(a: Int,
  b: String, 
  c: Boolean)(d: Int,
  e: String, 
  f: Boolean)

could cook like this

def something(a: Int,
              b: String, 
              c: Boolean)
             (d: Int,
              e: String, 
              f: Boolean)

@daniel-trinh
Copy link
Owner Author

One of the design goals for #7 and #8 are to simplify several multi-line
parameter formattings into one style, instead of several different ones:

If #7, #8, and #9 are implemented,

// Number 1
def something(a: Int,
  b: String, 
  c: Boolean)(d: Int,
  e: String, 
  f: Boolean)
// Number 2
def something(
  a: Int,
  b: String, 
  c: Boolean)(d: Int,
  e: String, 
  f: Boolean)
// Number 3
def something(
  a: Int,
  b: String, 
  c: Boolean)(
  d: Int,
  e: String, 
  f: Boolean)

Number 1, 2, and 3 would all become this:

def something(
  a: Int,
  b: String, 
  c: Boolean
)(
  d: Int,
  e: String, 
  f: Boolean
)

Without #7 and #8, currently, Number 1 might become

def something(a: Int,
              b: String, 
              c: Boolean)
             (d: Int,
              e: String, 
              f: Boolean)

Number 2 might become

def something(
  a: Int,
  b: String, 
  c: Boolean)
             (d: Int,
              e: String, 
              f: Boolean)

and Number 3 might become

def something(
  a: Int,
  b: String, 
  c: Boolean)(
    d: Int,
    e: String, 
    f: Boolean)

PR #4 would still be useful in the case of single line parameters:

def something(a: Int, b: String, c: Boolean)(d: Int, e: String, f: Boolean)

something(a, b, c)(d, e, f)

==>

def something(a: Int, b: String, c: Boolean)
             (d: Int, e: String, f: Boolean)

something(a, b, c)
         (d, e, f)

Having only one final style for the multi line case also happens to simplify
some of the uglier code I've had to implement to get alignParameters working
the way it does now.

Thoughts?

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