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

Bug 221711

Summary: [misc] Moving a file with D&D to overwrite another file creates a copy
Product: [Eclipse Project] JDT Reporter: Jean-Francois Lecomte <jflecomte>
Component: TextAssignee: JDT-Text-Inbox <jdt-text-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P4 CC: jerome_lanneluc, martinae
Version: 3.3.1   
Target Milestone: ---   
Hardware: PC   
OS: Windows 2000   
Whiteboard: stalebug

Description Jean-Francois Lecomte CLA 2008-03-06 14:10:15 EST
Build ID: I20080207-1530 (Win2000)
Build ID: M20071023-1652 (Linux)

Steps To Reproduce:
1. Create 2 packages, let say 'package_a' and 'package_b'.
2. Create a class named 'MyClass' in package_a.
3. Create a class named 'MyClass' in package_b.
4. Edit the class in package_a to make it different from the one in package_b.
5. Select the class in package_a and drag & drop it over package_b.
6. Click "Ok" when the "Move" dialog appears.
7. Answer "Yes" or "Yes To All" when prompt to confirm overwriting the file.

Everything looks fine. The package_a appears empty and the file in package_b is identical to the file that was in package_a.

8. Open the "Open Type" dialog (ctrl+shift+t) and search for the class named 'MyClass'.

Two files are found, one in package_a and one in package_b. It is possible to open the file in package_a, but it can not be found in the Package Explorer view. Performing a refresh on the Package Explorer won't help. Need to close and re-open the project to see the file in the Package Explorer. Note that the file in package_a is never removed from the file system. 

More information:
Comment 1 Martin Aeschlimann CLA 2008-03-07 09:27:15 EST
JDT Core is used here to move the compilation unit

ISourceManipulation.move(...)
Comment 2 Jerome Lanneluc CLA 2008-03-19 11:12:07 EDT
The problem occurs only if Java editors are opened on both MyClass.java.
In this case, the Java element delta is:
Test[*]: {CHILDREN}
	src[*]: {CHILDREN}
		a[*]: {CHILDREN}
			[Working copy] MyClass.java[-]: {MOVED_TO([Working copy] MyClass.java [in b [in src [in Test]]])}
		b[*]: {CHILDREN}
			[Working copy] MyClass.java[+]: {MOVED_FROM([Working copy] MyClass.java [in a [in src [in Test]]])}

However it looks like the Java editor is not reacting to this change and not closing the editor on a/MyClass.java.

As a consequence, the primary working copy still exists for this editor, and this working copy is returned in Open Type.

Moving to JDT/Text
Comment 3 Eclipse Genie CLA 2020-03-22 16:40:20 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. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. 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.