Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 72247

Summary: [typing] regression - Smart Paste doesn't indent enough after line starting with spaces
Product: [Eclipse Project] JDT Reporter: Markus Keller <markus.kell.r>
Component: TextAssignee: JDT-Text-Inbox <jdt-text-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: minor    
Priority: P3 CC: daniel_megert, hudsonr
Version: 3.0   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard: stalebug

Description Markus Keller CLA 2004-08-19 07:11:52 EDT
200408170800, default settings.

public class Dingsbums {
	public int m(int first,
                 int second) { // indented with spaces
		int i= first;
	}
}

- copy all 4 lines of method m() and then paste again
- expected: indentation preserved (at least for lines 3-4)
- was: several spaces deleted from 2nd line; lines 3-4 shifted to left by 1 tab:
	public int m(int first,
            int second) { // indented with spaces
	int i= first;
}
Comment 1 Dani Megert CLA 2004-08-19 10:29:35 EDT
I200408170800

Tom, looks like a computation problem when computing the number of tabs out of
the spaces.
Comment 2 Tom Hofmann CLA 2004-08-20 10:47:32 EDT
hm, the second parameter was deep-indented in the original code, but when
pasting,  it was re-aligned with the current formatting settings (which I assume
said to only double indent parameters on additional lines, but not deep-align
them). 

Since the correction on the second line pasted is taken as the difference in
white space that is applied to all following lines, everything after that is wrong.

If you configure the formatter to deep-align (it's called indent-on-column, I
believe) method declarations, the results will be ok.
Comment 3 Tom Hofmann CLA 2005-02-11 11:49:39 EST

*** This bug has been marked as a duplicate of 65317 ***
Comment 4 Tom Hofmann CLA 2005-05-31 10:19:41 EDT
*** Bug 96004 has been marked as a duplicate of this bug. ***
Comment 5 Tom Hofmann CLA 2005-05-31 10:21:38 EDT
Reopening as this is not about the continuation support, but rather about how we
paste code that has different formatting rules than the target document.

Always taking the second line to compute the shift amount leads to wrong results
if the format differs. 

Possible solutions:
- own transfer type, passing also the formatting context of the source document
(see bug 96004)
- use the *first* line as the reference if it includes leading white space
Comment 6 Randy Hudson CLA 2005-05-31 12:58:04 EDT
the case in bug 96004 was working properly in 3.0.
Comment 7 Tom Hofmann CLA 2006-08-14 09:44:44 EDT
Moving back to inbox.
Comment 8 Eclipse Genie CLA 2019-09-06 17:56:50 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.