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

Add option for block indentation of array literals #574

Closed
Ms2ger opened this issue Nov 9, 2015 · 4 comments
Closed

Add option for block indentation of array literals #574

Ms2ger opened this issue Nov 9, 2015 · 4 comments

Comments

@Ms2ger
Copy link
Contributor

Ms2ger commented Nov 9, 2015

-static ERROR_FORMAT_STRING_STRING: [libc::c_char; 4] = [
-    '{' as libc::c_char,
-    '0' as libc::c_char,
-    '}' as libc::c_char,
-    0 as libc::c_char,
-];
+static ERROR_FORMAT_STRING_STRING: [libc::c_char; 4] = ['{' as libc::c_char,
+                                                        '0' as libc::c_char,
+                                                        '}' as libc::c_char,
+                                                        0 as libc::c_char];

is not an improvement at all.

@nrc
Copy link
Member

nrc commented Nov 9, 2015

Looks OK to me - it's consistent with how we would format shorter arrays or functions, etc. Even if we did prefer this style here (I can sympathise that the large block of whitespace is sub-optimal) it's hard to imagine how you would choose between visual and block indent.

We should have an option for this I guess (since we do for most other places where you could choose either way). Changing the title accordingly.

@nrc nrc changed the title Poor formatting of multiline arrays Add option for block indentation of array literals Nov 9, 2015
@slyrz
Copy link

slyrz commented Nov 24, 2015

consistent with how we would format shorter arrays or functions, etc

But not consistent with the initialization of structs.

The current output might work with short variable names, short type signatures and few array items. Once any of these get larger, the formatting becomes problematic. Think of cryptographic algorithms where you have to declare large blocks of 64 bit constants. With one item per line almost flushed to the right, the source code will look very strange.

@hsivonen
Copy link
Member

I suggest adding a line break after [ in large array literals. Example of non-ideal formatting.

@marcusklaas
Copy link
Contributor

This was addressed in #893.

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

5 participants