Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 249225

Summary: [formatter] JavaScript formatting breaks down in presence of line comment
Product: [WebTools] JSDT Reporter: Wang Jialiang <starwhisperer>
Component: GeneralAssignee: wst.javascript <wst.javascript-inbox>
Status: CLOSED DUPLICATE QA Contact: Phil Berkland <berkland>
Severity: normal    
Priority: P3 CC: cmjaun, martin.von.zweigbergk, thatnitind
Version: 3.0.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Wang Jialiang CLA 2008-09-30 16:59:58 EDT
The formatting in JS editor sometimes doesn't handle comment mark "//" very well.  It causes incorrect (less) indent on the next line of the comments.
It doesn't happen everywhere, usually inside a deep code block.
Comment 1 Chris Jaun CLA 2008-11-20 12:03:44 EST
Hello,

Its helpful if you provide specific example code for these types of problems, including the starting state, the expected result, and the actual result.

If you could attach that information it would assist us in investigating this bug.

Thanks, 
Chris
Comment 2 Wang Jialiang CLA 2008-11-20 14:19:52 EST
if (!this.lib) {
    var lib = {
        string : {
            format : function(str, params) {
                // for
                for ( var i = 0; i < str.length; i++) {

                }

                return str;
            },

            escape : function(str) {

            }
        }
    };
}

We developed a fairly large JS library, and this snippet is just part of it.
If you format this code in Eclipse JavaScript Editor, you can see the lines after "//for" are misaligned.  

An interesting thing to note is that this misalignment only happens if you have the function escape placed after it.  If you remove function escape, the format is correct again.
Comment 3 Chris Jaun CLA 2009-09-15 11:03:10 EDT
Categorizing JSDT bugzillas for planning purposes.
Comment 4 Chris Jaun CLA 2010-02-26 13:31:25 EST
*** Bug 293242 has been marked as a duplicate of this bug. ***
Comment 5 Chris Jaun CLA 2010-06-22 14:18:28 EDT

*** This bug has been marked as a duplicate of bug 315234 ***