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

Summary: Better formatting of array declaration that contains object literals
Product: javascript Reporter: Vladimir Riha <vriha>
Component: EditorAssignee: Petr Pisl <ppisl>
Status: REOPENED ---    
Severity: normal    
Priority: P3    
Version: 7.3   
Hardware: PC   
OS: Linux   
Issue Type: ENHANCEMENT Exception Reporter:
Attachments: wrong formatting
expected behaviour

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.