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.
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).
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)
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; } });
Hi Petr, I prefer the first case (it's consistent with what I get for Java code).
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.
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.
This issue is related to bug #244224 (but not identical).
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.
Petr, Which issue is that (braces placement configuration) and what release is it targeted for?
Changeset: 17a1748c91ed Author: Roman Svitanic <rsvitanic@netbeans.org> Date: 2015-01-27 11:09 Message: #227007: Excessive indent for object declaration - fixed
Checkbox enabling/disabling continuation in this case has been added to the Formatting/JS/Braces category. Default is the current option (continuation is enabled).
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
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 } });
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)
Changeset: 5a77672424d2 Author: Roman Svitanic <rsvitanic@netbeans.org> Date: 2015-01-29 11:23 Message: #227007: Excessive indent for object declaration - reopening fixed
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 } });
(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.
I thought http://hg.netbeans.org/main-silver/rev/826be1a7464c was supposed to fix this problem. Is there a follow-up changeset?
Oh, I see now: http://hg.netbeans.org/main-silver/rev/5a77672424d2 I'll wait for the new nightly update. Thanks!
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
Verified in build 201501300002. Thank you!