↩ Back to the list of all bugs

Reported bug #4647524 at Monday July 24 2006, 12:37 PM GMT.

Current state: Open (as of time of reporting)

Radar link for Apple Developers

Product/Component:
Developer Tools
Severity/Classification:
Enhancement
Is It Reproducible?:
Always
Version/Build Number:
Xcode 2.3 (Xcode IDE: 744.0, Core: 747.0, ToolSupport: 733.0)
Problem Report Title:
Indentation logic errs on comments directly following semicolon

Problem Details:

Summary:
The indentation logic in Xcode reproducibly counts a line ending with a comment (// comments and /* comments */) directly following a semicolon without intermediary whitespace as the start of a new indentation step when some specific conditions are met (the line is not the first statement in a block).

Steps to Reproduce:
1. Make a new file in Xcode - a simple C file will do.
2. Make sure "Syntax-aware indentation" is enabled in Xcode Preferences -> Indentation. No option to indent // comments needs to be enabled.
3. Inside a block (an Objective-C method, a function or a plain block), type the contents between the dashes:
--
foo();
bar();// comment
--
4. Move the insertion point to at the end of the second line (with the comment), and press Enter.

Expected Results:
That the new line would be indented to the depth of the previous lines, as a new block has not begun and a new indentation depth is not warranted.

Actual Results:
The new line is indented one further step.

Regression:
The problem occurs for statements within a block that have been followed by previous statements. For more detailed information, see Notes below.

Notes:
Through testing I have concluded that the problem occurs under some very specific circumstances.

If the statement after which the comment immediately begins (no whitespace) is not the first inside its immediate block, the bug occurs and the following line is indented an extra step.

These two cases both cause the bug to appear:

--
{
    int x = 2;
    {
        int y;
        /* */
        foo();// comment
    }
}
--
{
    NSString *str = [NSString string];
    foo();/* comment */
}
--

While these cases don't cause the bug to appear:

--
{
    /** introductionary comment **/
    foo();// comment
}
--
void foo() {
    
    /* first comment */
    
    // second comment
    
    /**
    
     third
    
     comment
    
     */
    
    NSLog(@"only statement in block");// foo
}
--

No attachments.