Bug 303755 - [ltk] Deleting a file with open editor saves the changes first
Summary: [ltk] Deleting a file with open editor saves the changes first
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.5   Edit
Hardware: All All
: P4 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-24 09:12 EST by Jakub Jurkiewicz CLA
Modified: 2012-02-08 05:30 EST (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Jurkiewicz CLA 2010-02-24 09:12:45 EST
Build Identifier: I20100129-1300

When you try to delete a file with some unsaved changes you need to confirm the operation twice. Moreover there is no way to delete the file without saving the changes, so when you undo the deletion operation you always get the file with the changes saved.


Reproducible: Always

Steps to Reproduce:
1. Create new project
2. Create new file (e.g. test.txt)
3. Make some changes to the file - do NOT save the file
4. Choose the Delete option for the file - Delete Resources dialog appears asking for confirmation
5. Click OK -> Second Delete Resources dialog appears asking for a review of the information (stating that test.txt file has unsaved changes)
6. Click Continue -> the test.txt file gets saved and deleted.

There is no way to delete the file without the saving it's content.
Comment 1 Szymon Ptaszkiewicz CLA 2010-03-01 05:44:17 EST
When deleting the file with unsaved changes the second dialog from refactoring framework. When 'Continue' is clicked the file is deleted but before deletion the file gets saved. This means that when we undo the last operation we get the file with saved changes. The question is do we really want those changes to be saved after clicking 'Continue' or we should skip saving so undo will restore file without those changes? What is your opinion Daniel?
Comment 2 Dani Megert CLA 2010-03-01 06:39:22 EST
>There is no way to delete the file without the saving it's content.
Not true. Simply close the editor first.

Markus, see also bug 250714.
Comment 3 Dani Megert CLA 2010-03-01 06:43:21 EST
The file should not be saved. What we could do (and did until 3.4) is to delete the file but leave the editor open dirty.
Comment 4 Marek Chodorowski CLA 2012-02-07 05:00:53 EST
Daniel could you clarify why the file should not be saved?
Let's assume the following scenario:
1. User has edited existing file, for example he/she *added* several important lines to this file (without saving changes)
2. User clicked delete and confirmed decision (maybe accidentally)
3. User clicked undo

I would expect that in the next step, file with added lines is reverted.
Otherwise one step from undo is missing. Once I clicked undo I am expecting that exactly the same file content is displayed (content which was available before I clicked undo).
Of course it might be confusing to the user if he/she *removed* a few lines in step 1. But it seems to be the right behavior from undo operation perspective.

Alternatively, solution might be to explicitly ask user: save or discard.
Comment 5 Dani Megert CLA 2012-02-07 05:30:54 EST
(In reply to comment #4)
> Daniel could you clarify why the file should not be saved?
> Let's assume the following scenario:
> 1. User has edited existing file, for example he/she *added* several important
> lines to this file (without saving changes)
> 2. User clicked delete and confirmed decision (maybe accidentally)
> 3. User clicked undo
> 
> I would expect that in the next step, file with added lines is reverted.
> Otherwise one step from undo is missing. Once I clicked undo I am expecting
> that exactly the same file content is displayed (content which was available
> before I clicked undo).
Well, if the file would be saved after the undo, then it wouldn't be the exact same state as before the delete operation where the file was dirty.

Can you name me one app/OS which saves a dirty file before deletion?
Comment 6 Marek Chodorowski CLA 2012-02-08 03:58:43 EST
(In reply to comment #5)
> Well, if the file would be saved after the undo, then it wouldn't be the exact
> same state as before the delete operation where the file was dirty.
> 
> Can you name me one app/OS which saves a dirty file before deletion?

Yes, that's right. But I mentioned about file *content*. By file content I mean content which is currently visible to the user (sorry if it sounded ambiguously).
I just wanted to show one scenario when not saving changes may be confusing to users.

My question was why this file should not be saved? (is there any justification)
And what do you think about solution when we explicitly ask user: save or discard?
Currently dialog with: "File: [file_name] has unsaved changes" message is displayed and user can choose "back", "continue" or "cancel". Option "continue" seems to be a problem because user does not know what will happen with this file.

Regarding to your question, often "undo" operation allows to retrieve changes on existing file. "Delete" operation seems to be "permanent delete" and it is not possible to retrieve this file using "undo" operation.
Comment 7 Dani Megert CLA 2012-02-08 04:01:35 EST
> My question was why this file should not be saved? (is there any 
> justification)

Yes, the user didn't choose to save. There is no reason that this should be done behind the scenes.
Comment 8 Marek Chodorowski CLA 2012-02-08 05:10:13 EST
(In reply to comment #7)
> Yes, the user didn't choose to save. There is no reason that this should be
> done behind the scenes.

Ok, but it seems to be no reason to discard changes (behind the scenes) as well.

I would like to know what do you think about solution when we explicitly ask user: save or discard? Is it acceptable from your point of view?
Comment 9 Dani Megert CLA 2012-02-08 05:30:17 EST
(In reply to comment #8)
> (In reply to comment #7)
> > Yes, the user didn't choose to save. There is no reason that this should be
> > done behind the scenes.
> 
> Ok, but it seems to be no reason to discard changes (behind the scenes) as
> well.
> 
> I would like to know what do you think about solution when we explicitly ask
> user: save or discard? Is it acceptable from your point of view?

No, this is overkill. Already now you get a (second) dialog that warns you about unsaved changes when you start to delete such a file.