Community
Participate
Working Groups
I have my C++ code style set to insert two spaces for all types of indentation, never tabs. Say I have a .cpp file containing: ----------- int foo() { if (true) { void(0); } } int bar() { } ---------- Note that there's two spaces on the blank line in 'bar'. Now say I select and copy from 'foo', where the selection starts with the "i" of the "if" and ends with the ";" after the void(0). If I now put the cursor at the end of the two spaces on the empty line in 'bar' and paste, the "void(0);" line that is pasted is indented by six spaces instead of 4.
In fact I can end the selection with the closing "}" of the 'if' to paste the entire block, and then the pasted closing "}" also gets incorrectly indented by four spaces instead of two.
The problem seems to happen only if I select from the "i" of the "if" without selecting the whitespace that proceeds it. I guess the issue is that the "if" line in the clipboard then has less indentation than its body, and Eclipse fails to correct this to the code style in use when pasting. For what it's worth, I encountered this while selecting an 'if' clause out of an 'else-if' block, so there was no leading whitespace to select given that the 'if' was proceeded on the line by the 'else'.
There's a bug for that. *** This bug has been marked as a duplicate of bug 279358 ***