Community
Participate
Working Groups
Example: for (var i = 0;; ++i) { // empty } After formatting: for ( var i = 0;; ++i) { // empty } - formatter inserts extra space after opening bracket before "var".
There's a formatter option controlling this, you're certain it's not set to do this intentionally?
(In reply to comment #1) JS formatter profile - tab "White Space": when "Sort options by Syntax element" is selected - "After opening parenthesis" - everything is unchecked; when "Sort options by Java element" is selected - "Control statements" - 'for' - checked options are: before opening parenthesis, after comma in initialization, after comma in increments, after semicolon.
I have same problem. Also formatter works fine without var keyword for(i=0;i<10;i++) -> for (i = 0; i < 10; i++) but! for(var i=0;i<10;i++) -> for ( var i = 0; i < 10; i++) It's very annoying
Created attachment 215140 [details] Patch to fix bug 369785 The second parameter to printNextToken(), named considerSpaceIfAny, does _not_ mean "add a space if needed", but "add a space if none has been inserted yet".
Hey, will someone fix it? Bug is still not fixed in Web Tools 3.4.0 (Eclipse Java EE IDE for Web Developers. Version: Juno Release Build id: 20120322-1740).
Is any eclipse.org developer "eating his own dog food" (i.e. using JSDT)? It has annoying bugs in source formatter, and they are not fixed for years.
One year and three months of silence. Thank you, Lupo! But I can't apply your patch. I dont know how to do it.
When will this fix be added to production? It's quite bothersome.
Created attachment 230424 [details] alternate patch Here is an alternate patch. The other patch does fix the issue, but in the case of the first statement following the opening parenthesis of the for loop we should be honouring the "insert_space_after_opening_paren_in_for" formatter setting and not just hard coding what to do for var declarations in general. Its too late to get this in for 3.5, but we can definitely target this for 3.6 / 3.5.1.
*** Bug 357457 has been marked as a duplicate of this bug. ***
This is really good news! I'm glad we have a timeline for the fix. Hi Michael, I wonder if you guys have any plans for the following issue: https://bugs.eclipse.org/bugs/show_bug.cgi?id=353546 which seems to be more serious than this one as most of the complex JavaScript source files in our project are messed up after reformatting. This issue was initially spotted by us since 2008, it would be really helpful if it could catch some attention. Thanks a lot.
Chris, I have reviewed this patch and validated it resolves this problem. In my opinion the "alternate patch" is a more completed patch, so I recommend it to be included in 3.5.1. Could you officially complete this review?
Pushed to 3.5.1 and master.
Should this be in WTP 3.5.1 (and hence Kepler SR1 / 4.3.1)?
It seems this issue is only fixed for the regular for loop. In case of for each loop, there's still an extra space in front of the var keyword.
Comment #15 is still correct, the enhanced for loop is still bugged. for (var i = 0; i < list.length; i++) { // ... } works fine, but for in loop is still formatted as such: for ( var elem in list) { // ... } Tested with Eclipse Photon (4.8.0), Build id: 20180619-1200.