dfmt icon indicating copy to clipboard operation
dfmt copied to clipboard

Indentation of the function literals in the argument list

Open belka-ew opened this issue 6 years ago • 2 comments

Here is an example with a lambda and function literal, formatted with ./dfmt --max_line_length=80 test.d:

 void main()
 {
     object.toString(firstArgument12345678901234567890123456789012345678900,
             (const string anotherArgumentWithSomeRandomLongNameWhichIsJustVeryLong)
-                => x);
+            => x);
 
     object.toString(firstArgument12345678901234567890123456789012345678900,
             (const string anotherArgumentWithSomeRandomLongNameWhichIsJustVeryLong) {
-                return x;
-            });
+        return x;
+    });
 }
  1. I think that the lambda body should get additional identation in this case (as in the original code).
  2. Argument wrapping for the function literal is replaced with the indentation — I think indentation and wrapping should be combined there (as in the original code).

belka-ew avatar Apr 15 '20 08:04 belka-ew

Similar case:

void main() {
    foo!(
            (int _2345678901234567890123456789012345678901234567890123456789012345678901234567) => X(
            foo));
}

I think this is more bug than enhancement.

FeepingCreature avatar Apr 22 '20 12:04 FeepingCreature

as long as code behavior doesn't change by formatting I don't think it can be called a bug for a code formatter.

let's call this priority enhancement

about the wrapping: would probably be nice if it would put the => in the next line if it doesn't fit anymore or if it still fits then keep it there and otherwise just move the value to the next line.

WebFreak001 avatar Apr 22 '20 13:04 WebFreak001