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 227007 - Excessive indent for object declaration
Summary: Excessive indent for object declaration
Status: VERIFIED FIXED
Alias: None
Product: javascript
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 7.3
Hardware: All All
: P3 normal with 1 vote (vote)
Assignee: Roman Svitanic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-04 22:45 UTC by _ gtzabari
Modified: 2015-01-31 17:18 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description _ gtzabari 2013-03-04 22:45:24 UTC
Product Version: NetBeans IDE 7.3 (Build 201302132200)
Java: 1.7.0_15; Java HotSpot(TM) 64-Bit Server VM 23.7-b01
Runtime: Java(TM) SE Runtime Environment 1.7.0_15-b03
System: Windows 7 version 6.1 running on amd64; Cp1252; en_CA (nb)
User directory: C:\Users\Gili\AppData\Roaming\NetBeans\7.3
Cache directory: C:\Users\Gili\AppData\Local\NetBeans\Cache\7.3

Given:

	Object.defineProperty(this, "length", {
		enumerable: true,
		get: function()
		{
			return length;
		}
	});

Invoking code-format leaves spaces as-is. However, if I move the opening bracket to the next line:

	Object.defineProperty(this, "length",
        {
		enumerable: true,
		get: function()
		{
			return length;
		}
	});

then code-format will result in:

	Object.defineProperty(this, "length",
		{
			enumerable: true,
			get: function()
			{
				return length;
			}
		});

Expected behavior: identical indentation regardless of the opening-brace position. The indentation of the first case seems correct. The indentatino of the second case seems incorrect (one too many indents).
Comment 1 Vladimir Riha 2013-05-22 08:31:19 UTC
Reproducible (in my case there is even bigger indentation) 


Product Version: NetBeans IDE Dev (Build 201305192300)
Updates: Updates available
Java: 1.7.0_21; Java HotSpot(TM) Client VM 23.21-b01
Runtime: Java(TM) SE Runtime Environment 1.7.0_21-b11
System: Linux version 3.2.0-43-generic-pae running on i386; UTF-8; en_US (nb)
Comment 2 Petr Hejl 2013-07-16 12:25:32 UTC
There does not seem to be anything wrong. The whole object literal is continuation. Please at least specify what you would like to have in second case. Unfortunately there is no right or wrong in the formatter just personal preference.

Is it this:
    Object.defineProperty(this, "length",
    {
        enumerable: true,
        get: function()
        {
            return length;
        }
    });
or this?
    Object.defineProperty(this, "length",
        {
        enumerable: true,
        get: function()
        {
            return length;
        }
        });
I think current state is ok as well:
    Object.defineProperty(this, "length",
        {
            enumerable: true,
            get: function()
            {
                return length;
            }
        });
Comment 3 _ gtzabari 2013-07-16 14:48:38 UTC
Hi Petr,

I prefer the first case (it's consistent with what I get for Java code).
Comment 4 _ gtzabari 2013-07-16 14:50:12 UTC
Also, I think you should revisit the original post. I understand that an Object is a continuation, but it doesn't make sense that the position of the opening brace should impact the position of the closing brace.

Meaning, it's a continuation in both cases and as such the closing brace should retain the same indentation level. I consider this part to be a bug, not a personal preference.
Comment 5 _ gtzabari 2014-02-07 16:09:55 UTC
Petr,

Please take a minute to fix this problem. It's been over 11 months since I've reported it and it's crawling up my skin every time I see it.
Comment 6 _ gtzabari 2014-05-01 06:50:00 UTC
This issue is related to bug #244224 (but not identical).
Comment 7 Petr Hejl 2014-06-13 08:06:13 UTC
Well, I think this would be part of not yet implemented braces placement configuration. I believe this should be done at once otherwise we will get a messy and hard to maintain code.
Comment 8 _ gtzabari 2014-06-13 13:48:24 UTC
Petr,

Which issue is that (braces placement configuration) and what release is it targeted for?
Comment 9 Roman Svitanic 2015-01-27 10:07:31 UTC
Changeset: 17a1748c91ed
Author:    Roman Svitanic <rsvitanic@netbeans.org>
Date:      2015-01-27 11:09
Message:   #227007: Excessive indent for object declaration - fixed
Comment 10 Roman Svitanic 2015-01-27 10:12:03 UTC
Checkbox enabling/disabling continuation in this case has been added to the Formatting/JS/Braces category. Default is the current option (continuation is enabled).
Comment 11 Quality Engineering 2015-01-28 04:13:54 UTC
Integrated into 'main-silver', will be available in build *201501280002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/17a1748c91ed
User: Roman Svitanic <rsvitanic@netbeans.org>
Log: #227007: Excessive indent for object declaration - fixed
Task #227007 - Excessive indent for object declaration
Comment 12 _ gtzabari 2015-01-28 18:05:57 UTC
Product Version: NetBeans IDE Dev (Build 201501280002)
Java: 1.8.0_40-ea; Java HotSpot(TM) 64-Bit Server VM 25.40-b25
Runtime: Java(TM) SE Runtime Environment 1.8.0_40-ea-b22
System: Windows 7 version 6.1 running on amd64; Cp1252; en_CA (nb)
User directory: C:\Users\Gili\AppData\Roaming\NetBeans\dev
Cache directory: C:\Users\Gili\AppData\Local\NetBeans\Cache\dev

Reopening because this isn't fully fixed.

1. Top-level object declaration works correctly:

Object.defineProperty(this, "delayFunction",
{
});

2. But nested object declaration do not:

Object.defineProperty(this, "delayFunction",
{
	value:
		{
			wrongIndentation: true
		}
});
Comment 13 Quality Engineering 2015-01-29 04:16:25 UTC
Integrated into 'main-silver', will be available in build *201501290002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/826be1a7464c
User: Roman Svitanic <rsvitanic@netbeans.org>
Log: Minor improvements in JS Formatter (related to #227007)
Comment 14 Roman Svitanic 2015-01-29 10:23:09 UTC
Changeset: 5a77672424d2
Author:    Roman Svitanic <rsvitanic@netbeans.org>
Date:      2015-01-29 11:23
Message:   #227007: Excessive indent for object declaration - reopening fixed
Comment 15 _ gtzabari 2015-01-29 15:27:31 UTC
Something's not right.

I installed dev build 201501290002, with a clean userdir and tried exactly the use-case I gave you:

Object.defineProperty(this, "delayFunction",
{
	value:
		{
			wrongIndentation: true
		}
});

but the indentation is still wrong (I see your code changes in the changeset, but I don't see any practical difference when running the code). To clarify, I want the above to get indented as:

Object.defineProperty(this, "delayFunction",
{
	value:
	{
		wrongIndentation: true
	}
});
Comment 16 Roman Svitanic 2015-01-29 15:33:17 UTC
(In reply to _ gtzabari from comment #15)
> Something's not right.
> 
> I installed dev build 201501290002, with a clean userdir and tried exactly

Please wait until the next build, today's change has not been propagated into the daily build, yet. Thanks.
Comment 17 _ gtzabari 2015-01-29 15:37:26 UTC
I thought http://hg.netbeans.org/main-silver/rev/826be1a7464c was supposed to fix this problem. Is there a follow-up changeset?
Comment 18 _ gtzabari 2015-01-29 15:38:23 UTC
Oh, I see now: http://hg.netbeans.org/main-silver/rev/5a77672424d2

I'll wait for the new nightly update. Thanks!
Comment 19 Quality Engineering 2015-01-30 04:20:53 UTC
Integrated into 'main-silver', will be available in build *201501300002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/5a77672424d2
User: Roman Svitanic <rsvitanic@netbeans.org>
Log: #227007: Excessive indent for object declaration - reopening fixed
Task #227007 - Excessive indent for object declaration
Comment 20 _ gtzabari 2015-01-31 17:18:34 UTC
Verified in build 201501300002.

Thank you!