Navigation Menu

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

Formatter: names tuple bug #3915

Closed
kostya opened this issue Jan 18, 2017 · 5 comments
Closed

Formatter: names tuple bug #3915

kostya opened this issue Jan 18, 2017 · 5 comments

Comments

@kostya
Copy link
Contributor

kostya commented Jan 18, 2017

all this examples add extra spaces:

x = {bbbbbbb: 10,
  aaaaaa:  20}

x = {haha: 10,
  a:    20}

x = {a:     10,
  bbbbb: 20}
@bcardiff
Copy link
Member

The extra spaces is because of a buggy implementation while trying to align labels and the indentation.

What will be better?

a)

x = {bbbbbbb: 10,
     aaaaaa:  20}

x = {haha: 10,
     a:    20}

x = {a:     10,
     bbbbb: 20}

b)

x = {bbbbbbb: 10,
      aaaaaa: 20}

x = {haha: 10,
        a: 20}

x = {    a: 10,
     bbbbb: 20}

other?

@kostya
Copy link
Contributor Author

kostya commented Jan 18, 2017

when it newlined it formatted like this:

x = {
  a:     10,
  bbbbb: 20,
}

so may be add auto newline, or a)

@RX14
Copy link
Contributor

RX14 commented Jan 18, 2017

a is most consistent with what the formatter already does

@bcardiff
Copy link
Member

Let's go with option a) then.

@bcardiff
Copy link
Member

@spalladino spalladino changed the title formatter: names tuple bug Formatter: names tuple bug Jan 19, 2017
juanedi added a commit to juanedi/crystal that referenced this issue Jan 30, 2017
When the collection literal doesn't begin with a newline, contents are now aligned at the same column as the starting token, so this:

x = { foo: 1,
  bar: 2 }

... turns into this:

x = {foo: 1,
     bar: 2}

When a newline is present, keep indentation as before (ie. indent one level deeper). This means this:

x = {
    foo: 1,
  bar: 2
}

... turns into this:

x = {
  foo: 1,
  bar: 2,
}
juanedi added a commit to juanedi/crystal that referenced this issue Jan 30, 2017
juanedi added a commit to juanedi/crystal that referenced this issue Feb 10, 2017
When the collection literal doesn't begin with a newline, contents are now aligned at the same column as the starting token, so this:

x = { foo: 1,
  bar: 2 }

... turns into this:

x = {foo: 1,
     bar: 2}

When a newline is present, keep indentation as before (ie. indent one level deeper). This means this:

x = {
    foo: 1,
  bar: 2
}

... turns into this:

x = {
  foo: 1,
  bar: 2,
}
juanedi added a commit to juanedi/crystal that referenced this issue Feb 10, 2017
spalladino pushed a commit that referenced this issue Feb 10, 2017
When the collection literal doesn't begin with a newline, contents are now aligned at the same column as the starting token, so this:

x = { foo: 1,
  bar: 2 }

... turns into this:

x = {foo: 1,
     bar: 2}

When a newline is present, keep indentation as before (ie. indent one level deeper). This means this:

x = {
    foo: 1,
  bar: 2
}

... turns into this:

x = {
  foo: 1,
  bar: 2,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants