Bug 109104 - Editor save does not write to disk (intermittent)
Summary: Editor save does not write to disk (intermittent)
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows 2000
: P1 critical (vote)
Target Milestone: 3.1.1   Edit
Assignee: Dani Megert CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 104469 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-09-08 17:35 EDT by John Arthorne CLA
Modified: 2006-01-05 09:01 EST (History)
3 users (show)

See Also:


Attachments
screen shot (87.21 KB, image/jpeg)
2005-09-08 17:38 EDT, John Arthorne CLA
no flags Details
Patch which adds (currently failing) test case to UndoManagerTest (957 bytes, patch)
2005-09-20 11:57 EDT, Dani Megert CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description John Arthorne CLA 2005-09-08 17:35:33 EDT
Build: I20050906-1200

Several times while using this build, I have hit save in an editor but the
buffer contents have not been flushed to disk.  When this happens, the file on
disk has the same contents as the previous save, but the "Save" action is greyed
out and the dirty indicator (*) is gone from the editor tab.  There are no
errors in the log file or on the Java console.

The first couple of times this happened, I thought it was an error in the
debugger because my breakpoints and stepping were not lining up with the correct
code. However, it just happened again, and I opened the same file in Wordpad to
discover that the editor contents do not match the contents in Wordpad.  Each
time this happened, dirtying the editor again and hitting save again would flush
the correct contents to disk.

I have not been able to reproduce it consistently, but here is what I did the
most recent time it happened.

1) Did a search and replace in a Java file (Ctrl+F, Replace All)
2) Hit save.
3) Discovered that I replaced with the wrong thing
4) Hit Undo (Ctrl+Z)
5) Did another search and replace with the correct value
6) Hit Save.

The editor now looks correct, but the file on disk still looks like it was in
step 2). I will attach a screen shot in case it helps clarify.
Comment 1 John Arthorne CLA 2005-09-08 17:38:14 EDT
Created attachment 26973 [details]
screen shot

Here is a screen shot when in the bad state.  I had done a global search and
replace of "file.getAbsolutePath" and replaced with the field "filePath". 
After saving and seeing the errors, I hit undo and then replaced
"file.getAbsolutePath()" with "filePath" (note the extra brackets). Now the
Eclipse editor looks correct but in Wordpad I see the old value.
Comment 2 Dani Megert CLA 2005-09-20 10:46:22 EDT
Here's a simple test case to reproduce the problem:

1. open a text file (can be empty)
2. type something of lenght n
3. save
4. undo
5. type something of lenght n (which can differ from 2.)
==> editor is marked as not dirty and hence save does nothing.
==> lost work
Comment 3 Dani Megert CLA 2005-09-20 10:59:25 EDT
This bug is also in R3.1 and R3_1_maintenance but not in 3.0.2.
Comment 4 Susan McCourt CLA 2005-09-20 11:21:10 EDT
Dani - let me know if you need help on this.  
The undo would have restored the prior resource modification stamp, is it 
possible that the modification stamp was reincremented after the second change, 
which made it seem as if it were not dirty?....
Comment 5 Mike Wilson CLA 2005-09-20 11:40:11 EDT
Is it possible to fix this for R3.1.1?
Comment 6 Dani Megert CLA 2005-09-20 11:44:21 EDT
>Is it possible to fix this for R3.1.1?
That's my plan.
Comment 7 Dani Megert CLA 2005-09-20 11:57:32 EDT
Created attachment 27303 [details]
Patch which adds (currently failing) test case to UndoManagerTest
Comment 8 Dani Megert CLA 2005-09-20 12:13:51 EDT
The problem is the document's *next* modification counter which is set back upon
undo instead being left as is.

Fix is ready but needs some more testing.
Comment 9 Dani Megert CLA 2005-09-20 12:58:37 EDT
Committed to HEAD and released into I20050921-0010. If all tests pass and after
some more testing I'll backport it into this weeks 3.1.1 build.
Comment 10 Dani Megert CLA 2005-09-21 05:38:17 EDT
Verified in I20050921-0010.
Backported to R3_1_maintenance.
Comment 11 Benno Baumgartner CLA 2005-09-26 05:21:44 EDT
Verified using M20050923-1430
Comment 12 Dani Megert CLA 2006-01-05 09:01:12 EST
*** Bug 104469 has been marked as a duplicate of this bug. ***