Swiftformat: Wraparguments for wrong formatted function not working

Created on 24 Aug 2018  Â·  6Comments  Â·  Source: nicklockwood/SwiftFormat

I have a wrong formated code func foo(a: Int, b: Int, c: Int) { ... }

And when I use --wraparguments, it doesn't work. Wraparguments works only when it's is partially formatted:

  1. func foo(a: Int,
    2. b: Int) {

then beforefirst afterfirst works.

Is it possible to force format of top function, to afterfirst, when arguments are in one line?

Most helpful comment

@michalcickan it’s not possible currently. wraparguments will only rewrap functions that have already been wrapped onto multiple lines. I’ll consider adding an option for this.

All 6 comments

@michalcickan it’s not possible currently. wraparguments will only rewrap functions that have already been wrapped onto multiple lines. I’ll consider adding an option for this.

May or may not be the same, but I've had to disable _wrapArguments_ because formatting was going from this

    MultivaluedSection(multivaluedOptions: [.Insert, .Delete]
//                      ,
//                      header: "Multivalued TextField",
//                      footer: ".Insert adds a 'Add Item' (Add New Tag) button row as last cell."
                    ){

                        $0.addButtonProvider = { section in

to this

    MultivaluedSection(multivaluedOptions: [.Insert, .Delete]
//                                  ,
        //) {                                  header: "Multivalued TextField",
            $0.addButtonProvider = { section in

both with _after-first_ & _preserve_, i.e. a comment line was misplaced, a second was gone, and closing parenthesis / opening bracket was commented out, that of course triggered a syntax error.

Easy fix on our side, still wanted to point this out…

@pmanna thanka for reporting. This isn't really the same issue, but it looks like a serious bug and I'll get it fixed asap.

@pmanna the bug you reported is fixed in version 0.40.0.

@nicklockwood Thanks, great support!

@michalcickan swiftformat 0.41.0 now allows you to specify a --maxwidth option and will wrap arguments that exceed it automatically.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MaxDesiatov picture MaxDesiatov  Â·  3Comments

PompeiaPaetenari picture PompeiaPaetenari  Â·  4Comments

Cyberbeni picture Cyberbeni  Â·  4Comments

mdiep picture mdiep  Â·  3Comments

DagAgren picture DagAgren  Â·  4Comments