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

Bug 344724

Summary: [Undo] Ctrl-Z deletes a copied project with no way to recover it
Product: [Eclipse Project] Platform Reporter: surfingsteve
Component: IDEAssignee: Platform UI Triaged <platform-ui-triaged>
Status: CLOSED DUPLICATE QA Contact:
Severity: critical    
Priority: P3 CC: carl, daniel_megert, eclipse, emoffatt, kalyan_prasad, kiki, mattclark111, petter.isberg, pwebster, remy.suen, ruediger.herrmann, spam, yevshif
Version: 3.7   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=200424
Whiteboard:

Description surfingsteve CLA 2011-05-04 12:04:22 EDT
Build Identifier: 753 

If the focus is on the project explorer and you mistakenly type Ctrl-Z it will undo the previous action.  If the project you are working on is a copy of another project it will delete your current project with no way to recover your data.  If you go to edit->redo it will repeat the copy process but none of your work is saved.  Eclipse should not ever wholesale delete your project because of a mistaken key press without some kind of dialog box first.

This has caused me to loose a days worth of data on more than one occasion. 

Reproducible: Always

Steps to Reproduce:
1.Create Project
2.Copy/Paste/Rename Project
3.Ctrl-Z with focus on Project explorer irrevocable deletes your new project and all additions or changes.
Comment 1 Susan McCourt CLA 2011-05-31 13:05:43 EDT
This is a variant of bug 219901.  See the long discussion there. We tried to provide a band-aid for specific operations.  Undoing the "Copy the project" is the same kind of destructive undo as "undo new file" was in the original bug, but we didn't consider this.  

Bug 219901 comment 14 summarizes our discussions on this topic.  We unfortunately have not revisited this model for the 4.x stream as we had hoped at the time.  I think we need to revisit the workspace undo history, perhaps only make it available by special choice rather than focus-driven.
Comment 2 Majo no Kiki CLA 2011-11-12 07:44:31 EST
WORKAROUND:

Simple:
Copy the project, but continue to work on the *original* not the copy.  That way, if you undo, you only undo your backup.

Better:
In fact, you can copy the project *twice* to be very safe (then continue to work on the original.)  Then if you undo, you have de-copied only the *additional* copy.

Even better:
In fact, if you copy the project then "delete" the project (*without* checking the checkbox that says "delete content project from disk (can't be undone.)") this will remove the project from the project window, but keep all files intact on the disk.  (If you're doing this as a crude version control system, this is best anyway.)  Note that undo then undoes the delete -- *restoring* the project copy to the project window.  Much less harmful!

This is the second time I lost a day's work with this bug.  Hopefully those who come to this bug will see this and not have it happen twice themselves.

This bug still needs fixing though.
Comment 3 Majo no Kiki CLA 2011-11-12 07:57:04 EST
Oh, an interesting note:

I had these files open: strings.xml, main.xml and myproject.java open in the editor.  The .java file closed, but the .xml files did not.  This allowed me to save over the fresh re-copied project files and save at least that work.  (It prompted me if I wanted to save over the (newer) files on the disk -- which I vary carefully made sure I did.)

Sadly, the .java file -- the one with the most critical edits -- got closed and deleted when the undo happened, and so I lost the bulk of my work.

One tiny little fix would be to keep that window open as well.

I agree that a prompt would be very helpful, and an easy fix for now.
Comment 4 Daniel Rolka CLA 2014-07-09 08:59:20 EDT
I still see the issue in the build: 4.4-win32-x86_64

Daniel
Comment 5 Carl Gunther CLA 2014-08-13 23:43:33 EDT
I recently copied a project to a new project.  I did not specify using the default folder for this copied project, and incorrectly specified an external folder that I wanted to contain the project folder, rather than the new project's folder itself.  

This copied the project to that top-level folder, where it created a mess by cohabiting with other related projects whose own folders were in that top-level folder.

I then decided to use the Eclipse Undo feature to simply "undo" the mess and start over.  Instead of that, my entire folder, containing about ten projects, was deleted.  Each of these projects had its own .git sub-folder, and these were also deleted.

I was forced to recover from a backup of about a week earlier.  Fortunately, file recovery software was able to retrieve all source changes that I had made since then.  Still, it was a lot of work to restore this, and things could have been even worse.

This was using Indigo, so I'm not sure if this behavior (deleting the entire folder containing the last project copy, no matter what pre-existing stuff is in it) is still the behavior in later versions.  If it is, then I think you can see how undesirable this behavior is.
Comment 6 Petter Isberg CLA 2015-08-18 09:11:18 EDT
Just lost a folder full of projects due to this in Eclipse 4.4 SR1

I accidentally missed to name a project folder when I copied a project. This effectively made Eclipse turn my projects library folder into the new project folder. When realising this I chose to undo the copy project command.

Result: the entire folder with all projects were deleted without Eclipse asking for confirmation.
They were thankfully in a git-repo so I only lost uncommitted changes, but this could potentially delete a users entire documents folder, or any folder really where a project could be stored. Had this happened to me, I would have seriously considered switching development platform.

The fact that this has already been solved for new files creation ( https://bugs.eclipse.org/bugs/show_bug.cgi?id=219901 ) in 2008 and that this bug was filed in 2011 without any progress (?) does not make it any better.

Deleting entire folder structures full of files (even files unrelated to Eclipse) by simply hitting Ctrl-z should not be possible.
Comment 7 Matt Clark CLA 2015-12-06 04:41:40 EST
Just lost many hours of work to this bug running Eclipse 4.5.0. This bug needs to be prioritized. NOTHING should ever permanently be deleted without a warning dialog. Beyond that, ALL eclipse delete operations on Windows environments should move things to the recycle bin as a safety measure.

I would appreciate anyone's suggestions on how to get lost work back, but I fear there is no way.
Comment 8 Dani Megert CLA 2016-04-01 05:12:00 EDT

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