Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 347622 - [typing] Paste with imports doesn't work after using Breadcrumb
Summary: [typing] Paste with imports doesn't work after using Breadcrumb
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.8 M6   Edit
Assignee: Dani Megert CLA
QA Contact:
URL:
Whiteboard: fix candidate
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-30 06:24 EDT by Markus Keller CLA
Modified: 2012-03-15 05:43 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.