[PhpStorm 2016] Javascript code reformat issue

Hewwo~

I would like some help to find where I didn't set the javascript code style parameter right.
My issue is that the first method of an objet goes to the next line, while I would like to keep it on the same line.
Though I want second, third, fourth, etc to wrap... Only the first one should stay inline.
Exemples will do the talk.

This is what I want:

$('body').on('vclick', '.myTracking', function() {
myTracking($(this).attr("data-id"), $(this).attr("data-type"), $(this).attr("data-value"));
});

and this is what I get:

$('body')
.on('vclick', '.myTracking', function() {
myTracking($(this)
.attr("data-id"), $(this)
.attr("data-type"), $(this)
.attr("data-value"));
});

Here is a screen of my settings:

It was working fine on PhpStorm 10, but I can't get it back on PhpStorm 2016.

 

Hope someone will be able to help. Thanks

11 comments

Hello,

Please set Chained method calls to "Do not wrap". This should do the trick.

0

I want them to wrap... but not the first one...
If I set to "Do not wrap', it will place everything on the same line...
Might be a problem to read things afterward... ^^

0

Did you try 'Chop down if long' instead of 'Wrap always'?

0

I did, it will keep inline if there is two method, which I don't want... :/
Maybe it's a bug... As the preview on the right of the setting screen show it correctly...

0

To me, the resultant formatting exactly matches the one in preview:

 

 

Note: 'long' here means 'exceeds right margin' that can be set in Settings | Editor | Code Style, Right margin (columns)

0

Odd...
Do you mind to screen and zip every tab of the javascript code style plz?!
I will compare with my own settings when I will be back home in about 45 mins

0

It's default - only options I changed are 'Chop down if long' and 'Align when multiline' for chained calls. Note also that existing line breaks are kept by default on reformatting, so, if the call is already on a new line, it will be kept there and you run Format Code

0

I see...
Unfortunate, but it won't works...

It works in my exemple because it's small code, it won't with big one... :/

As exemple, ligne 22 on your screenshot, you have 2 chained method on the same line...
Unlike my screenshot which have x(), y(), z() on seperate line, but the first method x(), was kept on the first line.

0

My screenshot shows the resultant formatting with 'Chop down if long', and yours - 'wrap always'.

With 'wrap always' formatting looks as follows:

 

that, again, matches the preview...

0

Hewwo...

Sorry for the long silence...
I will try to reset my settings, maybe I checked something I shouldn't have...

Also, just to be sure... You're on PhpStorm 2016 right?! (Lastest version)

0

Please sign in to leave a comment.