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

Bug 558033

Summary: Saving multiple selected files after editing the files in the "Compare documents..." view will save all files and overwrite unselected files
Product: [Eclipse Project] JDT Reporter: Taro Kyo <taro_k>
Component: UIAssignee: Kalyan Prasad Tatavarthi <kalyan_prasad>
Status: CLOSED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: kalyan_prasad
Version: 4.13   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Current Behavior none

Description Taro Kyo CLA 2019-12-09 10:30:52 EST
Using latest Eclipse IDE for Java EE, stable 2019-09 R (4.13.0), build ID: 20190917-1200.

Steps to reproduce:

1. Create an empty Java project.
2. Create 2 empty class files. If they are not empty, backspace every text and save, so you have blank text files.
3. In the Project Explorer, select both empty class files.
4. While those two files are selected, right click on one of them to open the context menu.
5. In the context menu, navigate to "Compare With..." and click on "Each Other".
6. This will open the the "Compare documents" view.
7. In the view, at the bottom, type "whatever" in one of the class files. **DO NOT SAVE YET!**
8. In the other class file, type "something". **DO NOT SAVE YET!**
9. Close the "Compare documents" view. You should then get a dialog prompt asking you to save which documents.
10. Leave one of the documents unchecked/unselected, and then click on the "Save selected" button.
11. Reopen the 2 class files you edited.
12. Observe that both files are actually saved with "whatever" and "something".

Expected results:

One of the files should be an empty file.

Actual results:

Both files have text in them.
Comment 1 Noopur Gupta CLA 2019-12-10 01:01:42 EST
Kalyan, can you please check this?
Comment 2 Kalyan Prasad Tatavarthi CLA 2019-12-12 00:31:23 EST
(In reply to Taro Kyo from comment #0)
> Using latest Eclipse IDE for Java EE, stable 2019-09 R (4.13.0), build ID:
> 20190917-1200.
> 
> Steps to reproduce:
> 
> 1. Create an empty Java project.
> 2. Create 2 empty class files. If they are not empty, backspace every text
> and save, so you have blank text files.
> 3. In the Project Explorer, select both empty class files.
> 4. While those two files are selected, right click on one of them to open
> the context menu.
> 5. In the context menu, navigate to "Compare With..." and click on "Each
> Other".
> 6. This will open the the "Compare documents" view.
> 7. In the view, at the bottom, type "whatever" in one of the class files.
> **DO NOT SAVE YET!**
> 8. In the other class file, type "something". **DO NOT SAVE YET!**
> 9. Close the "Compare documents" view. You should then get a dialog prompt
> asking you to save which documents.
> 10. Leave one of the documents unchecked/unselected, and then click on the
> "Save selected" button.
> 11. Reopen the 2 class files you edited.
> 12. Observe that both files are actually saved with "whatever" and
> "something".
> 
> Expected results:
> 
> One of the files should be an empty file.
> 
> Actual results:
> 
> Both files have text in them.

I have not been able to reproduce this issue.

Are the two class files already open in java editor?
If so, you will see the typed text displayed in the class files, but one of the class files is not yet saved, as that file was not selected to be saved.
Comment 3 Kalyan Prasad Tatavarthi CLA 2019-12-12 01:08:24 EST
Created attachment 281207 [details]
Current Behavior

If you look at the attached gif, the change made in Cls2 in the compare editor is also shown in the Cls2 java editor, but the file change is not saved.
Comment 4 Taro Kyo CLA 2019-12-20 11:49:39 EST
Ah, I see it now. I was truly mistaken.

I thought the changes are discarded the moment the "Compare With..." window is closed, and the document in the Editor behind the "Compare With..." window is completely untouched, like how some of the diff tools I use would work on Ubuntu.

So it seems that when you have unsaved changes made in the "Compare With..." window, that unsaved changes are propagated to the document in the Editor behind it, and the document is marked as "Unsaved".

I didn't see the * appearing in the document at all until your mouse in the animation GIF pointed it out for me.

Sorry about that. This is resolved.
Comment 5 Taro Kyo CLA 2019-12-23 11:51:13 EST
Forgot to close ticket.