Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 350057 - Pasting from clipboard sometimes messing up indentation
Summary: Pasting from clipboard sometimes messing up indentation
Status: CLOSED DUPLICATE of bug 279358
Alias: None
Product: CDT
Classification: Tools
Component: cdt-editor (show other bugs)
Version: 8.0   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Anton Leherbauer CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-22 10:10 EDT by Jonathan Watt CLA
Modified: 2011-07-21 07:53 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Watt CLA 2011-06-22 10:10:45 EDT
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.
Comment 1 Jonathan Watt CLA 2011-06-22 10:13:24 EDT
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.
Comment 2 Jonathan Watt CLA 2011-06-22 10:21:08 EDT
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'.
Comment 3 Anton Leherbauer CLA 2011-07-21 07:53:24 EDT
There's a bug for that.

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