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

Keep multiline array literals at same indent. #29

Merged
merged 1 commit into from Oct 11, 2015

Conversation

rcorre
Copy link
Contributor

@rcorre rcorre commented Oct 11, 2015

This doesn't fix all issues with multiline arrays, but at least fixes this simple case:

If the current line and the line above both begin with an array literal, align
the current line with the above line.
Resolves #26.

Keeps multiline 2D array definitions aligned like so:
auto a = [
[1, 2, 3],
[1, 2, 3],
[1, 2, 3],
];

Previously they were aligned like so:
auto a = [
[1, 2, 3],
[1, 2, 3],
[1, 2, 3],
];

If the current line and the line above both begin with an array literal, align
the current line with the above line.
Resolves JesseKPhillips#26.

Keeps multiline 2D array definitions aligned like so:
auto a = [
  [1, 2, 3],
  [1, 2, 3],
  [1, 2, 3],
];

Previously they were aligned like so:
auto a = [
  [1, 2, 3],
  [1, 2, 3],
    [1, 2, 3],
];
whitebyte pushed a commit that referenced this pull request Oct 11, 2015
Keep multiline array literals at same indent.
@whitebyte whitebyte merged commit cc9197b into JesseKPhillips:master Oct 11, 2015
@whitebyte
Copy link
Collaborator

Thanks, it works. BTW what are other issues with arrays?

@rcorre
Copy link
Contributor Author

rcorre commented Oct 11, 2015

If you put the opening brace on a newline, you get:

auto a = 
[
[ 1, 2, 3 ],
[ 4, 5, 6 ],
[ 7, 8, 9 ]
];

I haven't actually found a ftplugin that gets it right though. For example, Ruby gives:

arr = 
  [
    [ 1, 2, 3 ],
    [ 4, 5, 6 ],
    [ 5, 6, 7 ]
]

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.

2D array literal indentation
2 participants