views:

84

answers:

2

Why am I getting this behavior right after the if block? Am I missing something?

for (;;)
    if (/*...*/)
    {
        // statements
    }

    // statements indented to match the if indentation instead of the for loop;
+4  A: 

Visual Studio 2010 appears to be riddled with editor bugs. Indentation is particularly hosed.

Just wait until it starts moving your cursor to the beginning of the line every time you type a ':'.

If you close the file and reopen it that sometimes fixes the issue...for a little while anyway.

Noah Roberts
+2  A: 

About the only way to keep VS doing indentation reasonably is to always use a block to enclose the statement controlled by a for, if, while, etc. In your case that would mean:

for (;;) 
{
    if (/* ... */)
    {
    // ...
    }
}
// further statements here indented to match for loop.
Jerry Coffin