Community
Participate
Working Groups
Overview: When long line of code is present in object, JavaScript formatter indents the whole object instead of wrapping of single long line. The long line stays unwrapped. Steps to Reproduce: 1. In Eclipse go to menu Window -> Preferences. Select JavaScript -> Code Style -> Formatter. Set Active profile to Java Conventions [built-in] (for this particular example, but the same behavior is preserved with all profiles). 2. Make JavaScript file with following content: --- start of code var A = Class.create({ initialize : function() { this.afterCancel = Prototype.emptyFunction; } }); var B = Class.create({ initialize : function() { this.afterOpen = this.afterSave = this.afterDelete = this.afterCancel = Prototype.emptyFunction; } }); --- end of code Note the long line of code (104 chars). 3. Format the source (Ctrl-Shift-F). Actual Results: --- start of code var A = Class.create({ initialize : function() { this.afterCancel = Prototype.emptyFunction; } }); var B = Class .create({ initialize : function() { this.afterOpen = this.afterSave = this.afterDelete = this.afterCancel = Prototype.emptyFunction; } }); --- end of code Note that contents of object was indented by extra 2 levels, but the long line of code is still unwrapped and even longer than before (112 chars). Expected Results: Example should stay unchanged, or at least the single long line should be wrapped somehow. Indentation in other regions of code should not change. Build Date & Platform: Eclipse Java EE IDE for Web Developers. Version: Indigo Release Build id: 20110615-0604
Confirmed. The newline between 'Class' and '.create' for var B is particularly annoying. org.eclipse.wst.jsdt.feature (1.3.1.v201108102009-7F78FXRFBBoPbXRPcHfz-uy) "Eclipse JavaScript Development Tools"
This bug has been there for almost five years now and reported many times. It's sad to see it still hasn't got fixed. There are some workaround for this issue. Break up the long lines and go for shorter variable names. Hope this could be fixed soon, if ever :(
It's absolutely insane that this bug exists almost nine years later. Has it ever been looked at?