dfmt icon indicating copy to clipboard operation
dfmt copied to clipboard

keep_line_breaks with line limit break some chains

Open belka-ew opened this issue 4 years ago • 3 comments

.\bin\dfmt.exe --keep_line_breaks=true --soft_max_line_length=120 .\test.d

 unittest
 {
     const expectedChains = [
         MyChainLinkBuilder("a").link("b").link.value,
-        MyChainLinkBuilder("c").link("абвгд").link("еёжз").value,
+        MyChainLinkBuilder("c").link("абвгд")
+        .link("еёжз").value,
     ];
 }

Not sure, what's going on here; the bug depends on the lenght of the array name, and the length of both elements.

belka-ew avatar Apr 14 '20 06:04 belka-ew

if it's at the line limit I would expect this to line break, what did you expect otherwise?

WebFreak001 avatar Apr 14 '20 07:04 WebFreak001

The line has only 65 columns, but I set the limit to 120.

This happens with ASCII strings as well. Here is an example with the same behaviour:

.\bin\dfmt.exe --keep_line_breaks=true --soft_max_line_length=120 --max_line_length=120 .\test.d

unittest
{
    const expectedChains = [
        MyChainLinkBuilder("a").link("b").link.value,
        MyChainLinkBuilder("c").link("adeddbcde").link("abdddccd").value,
    ];
 }

But the longest line has only 73 characters.

belka-ew avatar Apr 14 '20 07:04 belka-ew

oh in this case this is a kind-of regression with the new array formatter. Previously it would just put everything on the same line, breaking when it reaches the max line length, which is why you see a break at that point, but with the new array formatter it first tries to format each item and breaks before and after if the item, but it keeps the wrapping and doesn't try to reformat it anymore then.

WebFreak001 avatar Apr 14 '20 07:04 WebFreak001