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

Bug 347622

Summary: [typing] Paste with imports doesn't work after using Breadcrumb
Product: [Eclipse Project] JDT Reporter: Markus Keller <markus.kell.r>
Component: TextAssignee: Dani Megert <daniel_megert>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert
Version: 3.7   
Target Milestone: 3.8 M6   
Hardware: All   
OS: All   
Whiteboard: fix candidate

Description Markus Keller CLA 2011-05-30 06:24:25 EDT
I20110528-0800, already broken in 3.5.2

Paste with imports doesn't work after using Breadcrumb. Works again after closing/reopening editor.

Steps:
- paste the following into Package Explorer:

/////////////////////////////////////////////
package p;

public class Bar {

}

package p;

import java.io.File;
import java.io.FileInputStream;

public class Foo {

	void foo() {
		File f= null;
		FileInputStream fis= null;
	}

}
/////////////////////////////////////////////

- in the breadcrumb, click the triangle between p and Foo, and then click Bar
- go back to Foo.java
- select the 4 lines that define foo()
- Ctrl+C
- go to Bar.java
- paste into the body of Bar
=> imports not added

Also, when you select all in Foo.java and then copy, the folded import for FileInputStream is not copied.
Comment 1 Dani Megert CLA 2012-02-09 09:03:07 EST
I first thought that the fix for bug 296589 would also fix this one, but it looks like a slightly different retarget problem.
Comment 2 Dani Megert CLA 2012-02-09 09:28:51 EST
It's enough to switch to breadcrumb and back, to disable the action (only 'copy' is broken, 'paste' continues to be bound).
Comment 3 Dani Megert CLA 2012-02-09 12:26:01 EST
Oh boy, that was a hard one.

By default (lowest layer) we register TextNavigationAction(s) that call the native StyledText actions. The next layer registers its own enriched actions but with different action IDs (but same action definition IDs AKA command IDs). At this point two copy actions got registered but the last one won. At the JDT level we then replace the second one but leave the first one. This still works because the sequence is OK. When we switch to the breadcrumb and back, we unregister and then re-register all actions. Unfortunately, at this point, the one which got registered initially (TextNavigationAction) now comes last and wins.

Fixed in master (text): f7e9c6e267deffe8ad723ad4b8c99d360e585a7b
Comment 4 Dani Megert CLA 2012-02-09 12:26:13 EST
.
Comment 5 Dani Megert CLA 2012-03-15 05:43:44 EDT
Verified in I20120314-1800.