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

Reformatting objects completely messes up previous formatting #254

Open
WebFreak001 opened this issue Aug 5, 2016 · 1 comment

Comments

@WebFreak001
Copy link
Member

commented Aug 5, 2016

(edit note: this issue is not about broken struct formatting, it is about that dfmt should honor previous formatting of lines and not completely override it)

If I have a struct like this:

void main() {
    S s = {
        someStructMember1: 2,
        someStructMember2: 42,
        someStructMember3: null, // foobar
        someOtherMember1: objA,
        someOtherMember2: objB,
        someOtherMember3: 0,
        somethingMore: null,
        someFlagInThisStruct: -1
    };
}

it reformats it to this:

void main()
{
    S s = {
    someStructMember1:
        2, someStructMember2 : 42, someStructMember3 : null, // foobar
    someOtherMember1 : objA, someOtherMember2
            : objB, someOtherMember3 : 0, somethingMore : null, someFlagInThisStruct : -1};
    }

This formatting would only make sense if this was a one-line struct before formatting like a small config struct or arguments for a function (and still for that the indentations and new lines are still super ugly).

However before formatting this was a definition where every variable had its own line and IMO dfmt should format it accordingly if my statement was multiple lines before formatting or not.

This results in really ugly code right now if you use this on large code files without //dfmt off and //dfmt on blocks. Also I am not a fan of these comments because they are used way too often to actually result in good looking code. The formatter should take away most work of making the code look good and not add more work.

@Hackerpilot

This comment has been minimized.

Copy link
Collaborator

commented Aug 5, 2016

If I had to guess, the code that tries to figure out the difference between a struct literal and a function literal has messed up again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.