This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 215559 - Better formatting of array declaration that contains object literals
Summary: Better formatting of array declaration that contains object literals
Status: REOPENED
Alias: None
Product: javascript
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.3
Hardware: PC Linux
: P3 normal with 1 vote (vote)
Assignee: Petr Pisl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-15 16:48 UTC by Vladimir Riha
Modified: 2015-09-30 12:47 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
wrong formatting (59.62 KB, image/png)
2014-05-07 09:40 UTC, Christian Lenz
Details
expected behaviour (8.21 KB, image/png)
2014-05-07 09:41 UTC, Christian Lenz
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Riha 2012-07-15 16:48:56 UTC
Consider following snippet:

var bugs = [
        {id: "206836",
    title: "Title",
    priority: 1
}];

This is considered as formatted (Format action does nothing). I can imagine better result, for instance:


var bugs = [
    {id: "206836",
    title: "Title",
    priority: 1}];

Or something like that.


Product Version: NetBeans IDE Dev (Build 201207140002)
Java: 1.7.0; Java HotSpot(TM) 64-Bit Server VM 21.0-b17
System: Linux version 3.5.0-4-generic running on amd64; UTF-8; en_US (nb)
Comment 1 severo 2013-08-14 12:16:43 UTC
Yeah I experience the same problem. However in the preview it works :)
Comment 2 severo 2013-08-14 12:18:27 UTC
I am on netbeans-dev-201308122300
Comment 3 Petr Hejl 2013-08-15 20:22:19 UTC
For your sample my result is:
var bugs = [
    {id: "206836",
        title: "Title",
        priority: 1
    }];

If I configure wrap always for Object and Object Properties result is:

var bugs = [
    {
        id: "206836",
        title: "Title",
        priority: 1
    }];

You should definitely try 201308141142. Looks like duplicate of issue #234244.
Comment 4 Vladimir Riha 2013-08-19 06:56:57 UTC
Thanks for update, it seems better now, especially if I modify the wrapping or move curly brace to the [

var bugs = [{
        id: "206836",
        title: "Title",
        priority: 1
    }];

then this is considered formatted, which I agree with :)
Comment 5 Petr Hejl 2013-09-04 09:26:05 UTC
Ok, closing.
Comment 6 Christian Lenz 2014-05-07 09:39:34 UTC
I would like to reopen this ticket, if its better to use a new ticket then tell it me :).

I have similar formatting issues with object literals inside an array which is inside an object. Please see the 2 screenshots for more details.
Comment 7 Christian Lenz 2014-05-07 09:40:31 UTC
Created attachment 147156 [details]
wrong formatting

The arrows show what I expected.
Comment 8 Christian Lenz 2014-05-07 09:41:24 UTC
Created attachment 147157 [details]
expected behaviour

First one is ok, second one is what I got when I format the code and third is what I expect for foo.