Bug 21493 - Java editor dirty flag '*' should go away if all changes are undone
Summary: Java editor dirty flag '*' should go away if all changes are undone
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 2.0   Edit
Hardware: All All
: P3 normal with 19 votes (vote)
Target Milestone: 4.3 M3   Edit
Assignee: Dani Megert CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 2281 31853 32364 33419 39753 45503 46484 51342 58519 63907 68422 71264 76618 81549 82794 87472 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-07-11 12:42 EDT by Graham Johnson CLA
Modified: 2013-05-24 09:31 EDT (History)
34 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Graham Johnson CLA 2002-07-11 12:42:57 EDT
If I make any change to a newly opened Java file, an asterisk appears before 
the filename in the tab for the editor window, indicating it has been 
modified.  This asterisk (along with any underlying 'dirty' flags on the 
editor) should go away if the change is undone, but this is not currently the 
case.
Comment 1 Alvin Thompson CLA 2002-11-07 16:02:36 EST
is anyone fixing this? i get bitten by this shallow undo buffer all the time...
Comment 2 Alvin Thompson CLA 2002-11-07 16:08:57 EST
hmmm... somehow last comment wound up on the wrong bug...
Comment 3 Ed Burnette CLA 2003-02-07 12:48:24 EST
This happens on all text editors not just Java editors. Currently you have to 
close the editor and re-open it to get rid of the asterisk. Also it 
prompts 'filename has been modified. Save changes?' even though there are no 
changes (due to undo they have all been backed out).

I don't consider this an 'enhancement request'. It should be categorized as 
a 'normal' or 'minor' bug instead. This bug still happens in last week's 2.1 
integration (I20030129).

Comment 4 Jason Yip CLA 2003-03-18 22:29:34 EST
*** Bug 31853 has been marked as a duplicate of this bug. ***
Comment 5 Dani Megert CLA 2003-10-14 03:53:17 EDT
>Currently you have to close the editor and re-open it to get rid of the asterisk.
Not true, use File > Revert.
Comment 6 Dani Megert CLA 2003-10-27 03:27:00 EST
*** Bug 33419 has been marked as a duplicate of this bug. ***
Comment 7 Dani Megert CLA 2003-10-27 03:27:05 EST
*** Bug 45503 has been marked as a duplicate of this bug. ***
Comment 8 Nick Edgar CLA 2003-11-13 10:49:42 EST
*** Bug 46484 has been marked as a duplicate of this bug. ***
Comment 9 Dani Megert CLA 2004-02-09 06:02:40 EST
*** Bug 51342 has been marked as a duplicate of this bug. ***
Comment 10 Dani Megert CLA 2004-02-09 06:02:56 EST
*** Bug 32364 has been marked as a duplicate of this bug. ***
Comment 11 Dirk Bergstrom CLA 2004-04-12 18:01:20 EDT
I was going to file it against 3.0M8, but I see it's been around for 18 months.
 There's no Target Milestone for it, despite the 19 votes...
Comment 12 Debbie Wilson CLA 2004-04-14 15:32:07 EDT
*** Bug 58519 has been marked as a duplicate of this bug. ***
Comment 13 Dani Megert CLA 2004-05-26 06:24:03 EDT
*** Bug 63907 has been marked as a duplicate of this bug. ***
Comment 14 Wassim Melhem CLA 2004-06-23 18:02:17 EDT
*** Bug 68422 has been marked as a duplicate of this bug. ***
Comment 15 Dani Megert CLA 2004-08-03 03:20:39 EDT
*** Bug 71264 has been marked as a duplicate of this bug. ***
Comment 16 Cary Sweet CLA 2004-09-01 17:01:45 EDT
Seems like a simple change and I am seeing several editors supporting it. The 
latest one being TextPad.
Add a command into the undo/redo queue to turn the dirty flag on if a change 
occurs and the dirty flag is off.  The undo will remove it.  If you go past the 
last saved state during the undo, redo the dirty flag command in the queue
Comment 17 canson CLA 2004-09-14 22:20:10 EDT
It's been well over 2 years and I'm yet to see this bug resolved (yes, I second 
Ed Burnette, this is no enh.req, just plain bug). And, File->Revert is no 
panacea at all; the nuisance this bug causes is particularly irritating while 
working on half a dozen editors concurrently all of which complain about 
something changed you don't recall and can't see in undo stack when you want to 
close them.
This has become one of the top voted bugs of Eclipse, but still no attack to 
resolve it. Why?
Comment 18 Johan Walles CLA 2004-09-15 02:47:35 EDT
This is currently the seventh most voted for bug:

http://tinyurl.com/6be3z
Comment 19 Randy Hudson CLA 2004-09-15 10:44:34 EDT
(This bug is even older than 2 years. It is a dupe of bug 2281)

Kai, this one is the DUPE, but it has most of the votes and CC'ed e-mails.  
I'll let you decide which one to close.
Comment 20 Kai-Uwe Maetzel CLA 2004-09-15 11:08:09 EDT
*** Bug 2281 has been marked as a duplicate of this bug. ***
Comment 21 Kai-Uwe Maetzel CLA 2004-09-15 11:24:15 EDT
This item is explicitly mentioned on our 3.1 plan. Still, it is not our 
highest priority. 
Comment 22 canson CLA 2004-09-15 22:57:32 EDT
This is not a Java editor thing only, it's generic. Besides, bug #2281 seems to 
be filed before this one (but most people somehow have been forwarded to 21493 
in the past).
So I think 2281 is more fit to consolidate on unless votes will be lost on the 
way (btw, do votes really count at all?).
I guess this is rooted at some abstract base class(es) and not trivial to fix, 
but 3.1 is way too late man, we're getting older...
Comment 23 Leopold Welsch CLA 2004-09-16 03:29:15 EDT
Perhaps not high priority, but very annoying.

Seems like the votes for the duplicated bugs are not counted here as well as it
does not reflect bug 2281 was opened at 2001-10-10, i.e. 9 months before this
one. At least it would be fine if all votes for the duplicated would be shown as
well in this bug!
Comment 24 Johan Walles CLA 2004-09-16 04:42:36 EDT
An excellent suggestion from bug 2281 was that this feature should use the
quick-diff-against-the-version-on-disk feature to determine whether or not the
'*' should be displayed.

That would be truer than just looking in the undo-buffer, and since the
quick-diff is already working it sounds like that could be less work as well.

Regarding votes and duplicate bugs, please keep that discussion to
"http://bugzilla.mozilla.org/show_bug.cgi?id=25950".
Comment 25 Randy Hudson CLA 2004-09-16 10:35:50 EDT
Quick Diff runs on a low priority thread in the background.  The dirty bit has 
to be up-to-date all the time. Not to mention its an expensive operation and 
may be tuned to ignore whitespace changes, etc.

I'm surprised with as many CCs as there are that no one has tried to provide a 
patch, or at least understand why the fix is not simple.  I took a look 
myself.  It looks like AbstractDocumentProvider becomes dirty the first time 
the document is changed. So maybe if the provider allowed the dirty bit to be 
set explicitly, then it could be based on the undomanager's state.  So if the 
undoStack is empty, then the document is clean, unless the undo limit has been 
exceeded and commands have been purged at line 131 in DefaultUndoManager.
Comment 26 Thomas Arns CLA 2004-09-16 10:58:57 EDT
If the document has changed, it has changed. No different action for whitespace
differences!

If you open documents like bitmap files in eclipse, they are "dirty" the moment
they become visible ... this might be more difficult than checking the undo
buffer or do a "quick diff", which might be useful for text files.
Comment 27 Leopold Welsch CLA 2004-09-17 03:22:30 EDT
About how many are on this item, I would say, they are not all of them. Because,
even after duplicating you don't get an additonal notification nor are on the CC
nor are on the Vote-list. Yeah, it's a Bugzilla-Issue, but I wanna only mention it.

About the Undo: I personally do not understand, what it should make sense to
compare with the file on disk. The dirty-flag should be set only from the point
of view of the Editor in memory. The rest is non-sense (for me).

If the UndoBuffer was already exceeded, I could quite live with the fact, that
although the UndoBuffer is empty, the Dirty-Flag will never be restored again.
It only matter about how large the UndoBuffer will be resp. is. If it is e.g. 25
commands, and you have made 30 changes, then I do not see it useful to reset
Dirty-Flag after 25 undo-changes. The remaining 5 changes could never be told if
they are undone or not.
Comment 28 Johan Walles CLA 2004-09-17 04:01:32 EDT
I read the '*' to mean "the in-memory buffer has the same contents as the file
on disk", or conversely, if it isn't there I interpret it as "saving this buffer
won't change anything".

From that point of view, what changes have actually been made to the buffer
doesn't matter much.

However, it might be that the quick-diff isn't suitable for this purpose for
some reason, and it might also be the case that the '*' means other things to
other people than me.  But for my purposes, using quick-diff for this would be
good.  YMMV of course.
Comment 29 Johan Walles CLA 2004-09-17 04:03:34 EDT
Correction: I read the '*' to mean "the in-memory buffer's contents is different
from the contents of the file on disk".  Duh.
Comment 30 Leopold Welsch CLA 2004-09-17 04:38:53 EDT
Only out of interest: How do you change a file, while it is in Eclipse open? At
least under Windows it is not an easy task to perform. And if you do it via
tricky  way, you are responsible for it.

i.e. as long as no overflow of the UndoBuffer was done, the result to empty the
UndoBuffer should be the same as the file-content.

If you see another way to have a difference it would be fine to know about - as
long as the UndoBuffer did not exceed.
Comment 31 Johan Compagner CLA 2004-09-17 04:45:17 EDT
I read things like when emptying undo map then * should vanish again. But this 
should be always the case. Because the saved state should not be undomap == 0!

if i do this:

open a file (no *)
make one change (*)
make a second change (*)
save a file (no *)
make a change (*)
undo (no *)
another undo!! (*) (now i reverted to the state BEFORE the save!! so it is 
modified again...)
a redo (no *) (the save state..)

This is how it should work. How i make my undo/editor behaviour in the app i 
am/have written..
So save should not clear undo buffer.
Comment 32 Johan Walles CLA 2004-09-17 05:50:33 EDT
To answer Leopolds Questions:

Changing a file that is open in Eclipse using an external tool isn't a special
operation in any way, at least not on Linux.  If I change something with an
external tool, Eclipse pops up a dialog saying that the file has changed on disk
and asks me if I want to reload it.

The case when the quick-diff vs the undo-buffer algorithm differs is:

1. Open a file.
2. Type "foo".
3. Hit backspace three times to remove the "foo".

Quick diff now says that the file hasn't changed
The undo buffer says the file has changed.

I think quick-diff is correct and the undo buffer is wrong in this case.

I don't know what quick-diff really compares against, but for the '*' the best
thing would be to compare against the most recently loaded / most recently saved
version of the file.  If the file on disk is changed using an external tool,
we'd still prefer to compare against what Eclipse thinks the file on disk looks
like, not to the on-disk truth.
Comment 33 Randy Hudson CLA 2004-09-17 09:35:30 EDT
Johan,
In our GEF implementation, editor is clean when SavePointer == StackPointer.  
When commands are purged, save pointer is decremented until it becomes -1, 
which means the save location has been purged and can't be reached anymore.  So 
we added API like:

void markSaveLocation();
/*returns true if the current state is no the last saved state*/
boolean isDirty();
Comment 34 Dani Megert CLA 2004-10-21 04:30:59 EDT
*** Bug 76618 has been marked as a duplicate of this bug. ***
Comment 35 Dani Megert CLA 2004-12-20 12:41:17 EST
*** Bug 81549 has been marked as a duplicate of this bug. ***
Comment 36 Dani Megert CLA 2005-01-14 02:10:18 EST
*** Bug 82794 has been marked as a duplicate of this bug. ***
Comment 37 Dani Megert CLA 2005-02-08 07:21:00 EST
*** Bug 39753 has been marked as a duplicate of this bug. ***
Comment 38 Dani Megert CLA 2005-03-09 04:24:09 EST
*** Bug 87472 has been marked as a duplicate of this bug. ***
Comment 39 Dani Megert CLA 2005-04-20 12:04:22 EDT
Fixed in HEAD.
Available in builds > 20050420.
Comment 40 eric R CLA 2012-10-19 10:37:00 EDT
If I drag a file ( .txt for example) to eclipse and open it,then for this file the bug is still there.
Comment 41 Dani Megert CLA 2012-10-24 04:03:09 EDT
(In reply to comment #40)
> If I drag a file ( .txt for example) to eclipse and open it,then for this
> file the bug is still there.

See bug 214351.