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 225990 - Enhance javascript array indentation options
Summary: Enhance javascript array indentation options
Status: NEW
Alias: None
Product: javascript
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 7.3
Hardware: PC Windows 7
: P3 normal with 4 votes (vote)
Assignee: Petr Pisl
URL:
Keywords:
: 231318 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-02-11 17:19 UTC by powellke
Modified: 2015-09-09 11:27 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
IDE log (656.36 KB, text/plain)
2013-02-11 17:19 UTC, powellke
Details

Note You need to log in before you can comment on or make changes to this bug.
Description powellke 2013-02-11 17:19:22 UTC
Product Version = NetBeans IDE 7.3 RC2 (Build 201302050851)
Operating System = Windows 7 version 6.1 running on x86
Java; VM; Vendor = 1.6.0_23
Runtime = Java HotSpot(TM) Client VM 19.0-b09

I'm developing an ExtJS app and I am unable to get the Source | Format command to format my JavaScript the same as it did with NetBeans 7.2. It is adding extra indentions in places. I've gone through the various options and haven't been able to find any combination that works the same as 7.2.

The following example is formatted by 7.2 and is what I'd like to get (7.3 example follows this example...):

Ext.define('Needs.view.NeedEditor', {
    extend: 'Ext.form.Panel',
    alias: 'widget.needs-need-editor',

    requires: [
    'ASEC.view.ItemSelector',
    'ASEC.store.Platforms',
    'ASEC.store.SidTraces',
    'ASEC.store.Challenges',
    'Needs.controller.NeedEditorController'
    ],
    controller: 'Needs.controller.NeedEditorController',

    initComponent: function() {
        var me = this;

        Ext.apply(me, {
            layout: 'fit',
            border: false,
            trackResetOnLoad: true,
            bodyStyle: {
                backgroundColor: 'transparent'
            },
            padding: 10,

            items: [{
                autoHeight: true,
                xtype: 'tabpanel',
                plain: true,
                padding: '0 0 5 0',
                deferredRender: false,
                items: [{
                    title: 'Details',
                    layout: 'anchor',
                    bodyPadding: 10,
                    border: false,
                    autoScroll: true,
                    defaults: {
                        anchor: '95%',
                        labelWidth: 100
                    },
                    items: [{
                        xtype: 'textfield',
                        fieldLabel: 'Title',
                        name: 'name',
                        emptyText: 'Enter need name',
                        allowBlank: false,
                        afterLabelTextTpl: '<span style="color:red;font-weight:bold" data-qtip="Required">*</span>'
                    }, {
                        xtype: 'textarea',
                        fieldLabel: 'Description',
                        name: 'description',
                        emptyText: 'Enter a description to further define the need.',
                        allowBlank: true
                    }, {
                        xtype: 'combobox',
                        name: 'platformId',
                        itemId: 'platformCombo',
                        fieldLabel: 'Platform',
                        emptyText : 'Select platform',
                        store: Ext.create('ASEC.store.Platforms'),
                        editable: false,
                        displayField: 'name',
                        valueField: 'id'
                    }, {
                        xtype: 'textfield',
                        fieldLabel: 'Source',
                        name: 'source',
                        emptyText: 'Identify how/from whom the need was identified.',
                        allowBlank: true
                    }, {
                        xtype: 'textfield',
                        fieldLabel: 'PM Priority',
                        name: 'priority',
                        emptyText: 'Enter the priority of the need relative to the other needs in this module.',
                        allowBlank: true
                    }, {
                        xtype: 'textfield',
                        fieldLabel: 'Timeframe',
                        name: 'timeframe',
                        emptyText: 'Enter the date or system increment/release by which the need should be met.',
                        allowBlank: true
                    }, {
                        xtype: 'numberfield',
                        minValue: 1,
                        maxValue: 9,
                        fieldLabel: 'TRL Desired',
                        name: 'trlDesired',
                        emptyText: 'Enter the minimum Technology Readiness Level of the desired solution for this need.',
                        allowBlank: true
                    }]
                }]
            }],

            buttons: [{
                text: 'Save',
                iconCls: 'silk_disk',
                itemId: 'saveButton',
                formBind: true
            }, {
                text: 'Cancel',
                itemId: 'cancelButton'
            }]
        });

        me.callParent(arguments);
    }
});


And the following example is what 7.3 gives me:

Ext.define('Needs.view.NeedEditor', {
    extend: 'Ext.form.Panel',
    alias: 'widget.needs-need-editor',
    requires: [
        'ASEC.view.ItemSelector',
        'ASEC.store.Platforms',
        'ASEC.store.SidTraces',
        'ASEC.store.Challenges',
        'Needs.controller.NeedEditorController'
    ],
    controller: 'Needs.controller.NeedEditorController',
    initComponent: function() {
        var me = this;

        Ext.apply(me, {
            layout: 'fit',
            border: false,
            trackResetOnLoad: true,
            bodyStyle: {
                backgroundColor: 'transparent'
            },
            padding: 10,
            items: [{
                    autoHeight: true,
                    xtype: 'tabpanel',
                    plain: true,
                    padding: '0 0 5 0',
                    deferredRender: false,
                    items: [{
                            title: 'Details',
                            layout: 'anchor',
                            bodyPadding: 10,
                            border: false,
                            autoScroll: true,
                            defaults: {
                                anchor: '95%',
                                labelWidth: 100
                            },
                            items: [{
                                    xtype: 'textfield',
                                    fieldLabel: 'Title',
                                    name: 'name',
                                    emptyText: 'Enter need name',
                                    allowBlank: false,
                                    afterLabelTextTpl: '<span style="color:red;font-weight:bold" data-qtip="Required">*</span>'
                                }, {
                                    xtype: 'textarea',
                                    fieldLabel: 'Description',
                                    name: 'description',
                                    emptyText: 'Enter a description to further define the need.',
                                    allowBlank: true
                                }, {
                                    xtype: 'combobox',
                                    name: 'platformId',
                                    itemId: 'platformCombo',
                                    fieldLabel: 'Platform',
                                    emptyText: 'Select platform',
                                    store: Ext.create('ASEC.store.Platforms'),
                                    editable: false,
                                    displayField: 'name',
                                    valueField: 'id'
                                }, {
                                    xtype: 'textfield',
                                    fieldLabel: 'Source',
                                    name: 'source',
                                    emptyText: 'Identify how/from whom the need was identified.',
                                    allowBlank: true
                                }, {
                                    xtype: 'textfield',
                                    fieldLabel: 'PM Priority',
                                    name: 'priority',
                                    emptyText: 'Enter the priority of the need relative to the other needs in this module.',
                                    allowBlank: true
                                }, {
                                    xtype: 'textfield',
                                    fieldLabel: 'Timeframe',
                                    name: 'timeframe',
                                    emptyText: 'Enter the date or system increment/release by which the need should be met.',
                                    allowBlank: true
                                }, {
                                    xtype: 'numberfield',
                                    minValue: 1,
                                    maxValue: 9,
                                    fieldLabel: 'TRL Desired',
                                    name: 'trlDesired',
                                    emptyText: 'Enter the minimum Technology Readiness Level of the desired solution for this need.',
                                    allowBlank: true
                                }]
                        }]
                }],
            buttons: [{
                    text: 'Save',
                    iconCls: 'silk_disk',
                    itemId: 'saveButton',
                    formBind: true
                }, {
                    text: 'Cancel',
                    itemId: 'cancelButton'
                }]
        });

        me.callParent(arguments);
    }
});
Comment 1 powellke 2013-02-11 17:19:33 UTC
Created attachment 131256 [details]
IDE log
Comment 2 Petr Hejl 2013-02-11 20:55:50 UTC
Basically there was no formatter in 7.2, just some basic reindentation.

Can you narrow your samples? What particular thing you don't like? Is it the array indentation?
Comment 3 powellke 2013-02-12 14:38:28 UTC
Yes. The main thing that stood out as different is the way arrays of objects are indented.

I prefer this:

    items: [{
        name: 'Keith',
        age: 40
    }, {
        name: 'Frank',
        age: 52
    }]

over this:

    items: [{
            name: 'Keith',
            age: 40
        }, {
            name: 'Frank',
            age: 52
        }]

If I put the opening and closing curly brackets on lines by themselves, the indention make sense. It's just different than I'm used to. 

    items: [
        {
            name: 'Keith',
            age: 40
        }, {
            name: 'Frank',
            age: 52
        }
    ]

I like that the formatter properly indents simple arrays such as:

    requires: [
        'Ext.panel.Panel',
        'Ext.form.field.Checkbox'
    ] 

Thanks.



(In reply to comment #2)
> Basically there was no formatter in 7.2, just some basic reindentation.
> 
> Can you narrow your samples? What particular thing you don't like? Is it the
> array indentation?
Comment 4 jdavidbakr 2013-02-15 20:04:10 UTC
I've been playing with the RC for 7.3 (love the new features btw) but I'm running into this issue with the javascript formatter doing strange things as well.  I'm using MooTools library and compiling it via Packager.  This requires something like this at the top of each js file:

/*
---
provides: PackageName
requires:
 - Core/Options
 - Core/Events
 - Core/Fx.Tween
...
*/

The packager is pretty picky about not having any space on the line before the "---", "provides", "requires", and "..." lines.  The 7.2 version left these comment blocks as they were, but re-formatting the comment blocks are breaking my scripts.  I'd personally prefer that the stuff inside comment blocks be left alone by any formatter.

I've noticed that I get some wonky indentations when I carriage return into a new line as well, but haven't studied it enough to know what is happening.  I will say it seems to occur an awful lot when I'm inside of an object (i.e. deep in some MooTools class functions)
Comment 5 Petr Hejl 2013-02-18 15:50:05 UTC
(In reply to comment #4)
Please always file a separate issue. Do not hijack issue filed for different problem.

> I've been playing with the RC for 7.3 (love the new features btw) but I'm
> running into this issue with the javascript formatter doing strange things as
> well.  I'm using MooTools library and compiling it via Packager.  This requires
> something like this at the top of each js file:
> 
> /*
> ---
> provides: PackageName
> requires:
>  - Core/Options
>  - Core/Events
>  - Core/Fx.Tween
> ...
> */
> 
> The packager is pretty picky about not having any space on the line before the
> "---", "provides", "requires", and "..." lines.  The 7.2 version left these
> comment blocks as they were, but re-formatting the comment blocks are breaking
> my scripts.  I'd personally prefer that the stuff inside comment blocks be left
> alone by any formatter.
Fixed as issue #226282.

> 
> I've noticed that I get some wonky indentations when I carriage return into a
> new line as well, but haven't studied it enough to know what is happening.  I
> will say it seems to occur an awful lot when I'm inside of an object (i.e. deep
> in some MooTools class functions)
It is indenter related. Please file an issue with a reproducible test case. Thanks.
Comment 6 Petr Hejl 2013-06-18 11:20:45 UTC
*** Bug 231318 has been marked as a duplicate of this bug. ***
Comment 7 severo 2013-08-14 12:15:11 UTC
In 7.4
Objects are not indented at all!
Only functions


(function($) {

  $.widget("zevero.desktop", {
  // Default options.
  options: {
  topHeight:35,
  bottomHeight:30,
  iconWidth:100,
  iconHeight:100,
  menu: [
  {text: 'Design', click: function() {
    $('#jud-design').toggle();
  }, right:true }
...

thats just horrible!

However in the preview its just working fine! (Would be nice if it was editable, so I could look whats the difference)
Comment 8 Petr Hejl 2013-08-14 12:35:10 UTC
(In reply to severo from comment #7)
> In 7.4
> Objects are not indented at all!
> Only functions
> 
> 
> (function($) {
> 
>   $.widget("zevero.desktop", {
>   // Default options.
>   options: {
>   topHeight:35,
>   bottomHeight:30,
>   iconWidth:100,
>   iconHeight:100,
>   menu: [
>   {text: 'Design', click: function() {
>     $('#jud-design').toggle();
>   }, right:true }
> ...
> 
> thats just horrible!
> 
> However in the preview its just working fine! (Would be nice if it was
> editable, so I could look whats the difference)

Please do not hijack issues. File a separate one. As far as I can tell your sample works ok in today daily build. Please provide a full steps to reproduce.