Community
Participate
Working Groups
Build ID: M20071023-1652 Steps To Reproduce: Notice the "x = y;" and return lines. They are indented as if they was inside the previous statement. Select the entire method and hit Control-I to reindent the selection. If you remove the "()" from the q function call then the indentation becomes correct again. public int lineCount () { e = c ? q () : a; x = y; return lines.size (); } More information:
Can you give exact steps how you came to this code? Did you use 'Format' or 'Correct Indentation'?
The way I write Java code is, <characters...><Enter-key><Tab-key> <characters...><Enter-key><Tab-key> ... and so on. I rarely use Control-I (reindents a selected region). I do 99.9% of everything with just the Tab key. (I use the Emacs bindings if that makes a difference.) The Format operation, which according to the Preference pages is bound to Control-Shift-F is an operation I didn't know existed until you mentioned it. I don't see a Correct Indentation operation on the Keys Preference page so I don't know which operation that would be. The two formatting operations I use are the ones bound to Tab and to Control-I. To reindent a region I usually do, <tab><beginning-of-line><next-line> <tab><beginning-of-line><next-line> ... rather than selecting a region and typing Control-I to reindent the entire region. I discovered this example by simply noticing the problem as I was typing it in (I was using names like regionStartOffset rather than names like "b" but...). When I got to the line where I wanted to type "x = y;" I hit the Tab and noticed that the cursor was in the wrong place. I went ahead and typed in the "x = y;" and tried to reindent the line with <beginning-of-line><Tab> and it stayed where it was. I played with it, couldn't get it to stay at any other column, and finally decided it was an indentation bug and not a syntax mistake like a forgotten ")" or something. Then I started simplyfying the code. I removed comments, made all of the identifiers single letters, turned complex expressions like a+b+c into single names like c, eliminated function call parameter, etc. until I ended up with the simple example I sent in.
That's 'Source > Correct Indentation'
*** This bug has been marked as a duplicate of bug 65463 ***