Skip to content

Add option for block indentation of array literals #574

Closed

Description

@Ms2ger
-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.

Activity

  1. nrc commented on Nov 9, 2015

    @nrc
    Member

    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.

  2. changed the title [-]Poor formatting of multiline arrays[/-] [+]Add option for block indentation of array literals[/+] on Nov 9, 2015
  3. slyrz commented on Nov 24, 2015

    @slyrz

    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.

  4. hsivonen commented on Jan 11, 2016

    @hsivonen

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

  5. marcusklaas commented on May 13, 2016

    @marcusklaas
    Contributor

    This was addressed in #893.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions