This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 21237 - Redo should be possible after save
Summary: Redo should be possible after save
Status: VERIFIED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: Actions/Menu/Toolbar (show other bugs)
Version: 3.x
Hardware: PC All
: P2 blocker with 25 votes (vote)
Assignee: Miloslav Metelka
URL:
Keywords: PLAN
: 120981 138591 177504 184094 186983 (view as bug list)
Depends on: 204963 204965 205113
Blocks:
  Show dependency tree
 
Reported: 2002-03-06 12:22 UTC by tboerkel
Modified: 2011-11-30 15:36 UTC (History)
12 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
failing test cases (14.06 KB, patch)
2010-11-25 18:45 UTC, err
Details | Diff
Redo after Save diff (30 failing tests) (109.70 KB, patch)
2011-11-08 15:34 UTC, Miloslav Metelka
Details | Diff
Additional tests (15.64 KB, patch)
2011-11-30 15:36 UTC, err
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description tboerkel 2002-03-06 12:22:51 UTC
Undo is possible after doing a save, but redo not.
Comment 1 Marek Grummich 2002-07-22 12:11:23 UTC
Set target milestone to TBD
Comment 2 Marek Grummich 2002-07-22 12:15:19 UTC
Set target milestone to TBD
Comment 3 Miloslav Metelka 2007-02-05 08:55:24 UTC
This request needs to be implemented in the CloneableEditorSupport in
openide/editor.
The current algorithm adds extra undoable edits at time when file save is
peformed. Undoing that edit makes the file modified while redo makes it unmodified.
It works fine but the problematic case is save after redo because it adds that
extra UE into the middle of the undo queue which throws away the rest of the
queue (the undone edits).
The current algorithm needs to be changed. IMHO the only way is to wrap each UE
coming from the document with an extra UE class and have there an extra
 boolean savePerformedAfterThisEdit;
whether save was performed after that edit was done. If this boolean would be
set to true then the undo of the wrapped item would call markModified() and the
redo would do markUnmodified(). The CES would hold a pointer to the wrapper UE
 WrapperUndoableEdit lastSaveEdit;
corresponding to the last save operation. Before changing the value of
lastSaveEdit (because of a new save operation) it would first clear the
lastSaveEdit.savePerformedAfterThisEdit flag.

Reassigning to openide/editor for further evaluation.
Comment 4 Antonin Nebuzelsky 2008-04-17 15:15:16 UTC
Reassigning to new module owner mslama.
Comment 5 Peter Pis 2010-04-09 12:53:45 UTC
*** Bug 177504 has been marked as a duplicate of this bug. ***
Comment 6 nbphpuser 2010-04-09 13:57:47 UTC
Duplicates

120981
168303
138591
Comment 7 Vitezslav Stejskal 2010-04-14 08:42:08 UTC
*** Bug 138591 has been marked as a duplicate of this bug. ***
Comment 8 Vitezslav Stejskal 2010-04-14 08:42:54 UTC
*** Bug 184094 has been marked as a duplicate of this bug. ***
Comment 9 Vitezslav Stejskal 2010-06-01 09:14:54 UTC
*** Bug 120981 has been marked as a duplicate of this bug. ***
Comment 10 Vitezslav Stejskal 2010-06-01 09:15:23 UTC
*** Bug 186983 has been marked as a duplicate of this bug. ***
Comment 11 Vitezslav Stejskal 2010-06-23 09:01:04 UTC
*** Bug 138591 has been marked as a duplicate of this bug. ***
Comment 12 shiroamada 2010-09-10 02:40:54 UTC
I can't imagine since 3.3 this feature haven't implement.. this is basic text editor function, I hope Netbeans developer should take serious on this. I tried 6.10 M1 this feature still haven't fix it... please do something.
Comment 13 David Strupl 2010-09-10 17:35:41 UTC
shiroamada please don't change bug priorities unless they are assigned to yourself.
Comment 14 Miloslav Metelka 2010-10-21 13:01:22 UTC
I understand your frustration. I used to think that once we've implemented automatic-trailing-whitespace-removal then we would only be able to implement Redo-after-save in case the ATWR would be off (since ATWR generates edits that overwrite rest of UndoManager's queue) which of course gave RAS much less importance. But recently I've got an idea that we could possibly implement RAS with ATWR on. I  need some more thinking about a concrete implementation but it should be feasible.
Comment 15 zombat 2010-10-21 17:30:55 UTC
It's hard to believe that this bug has been open for eight years.  I have also suffered work loss from this issue, it's simply not intuitive or expected behaviour.  I hope this gets re-prioritized and taken seriously.
Comment 16 nbphpuser 2010-11-24 20:42:19 UTC
Excuse me, but why this bug has no P1 or P2 priority? It's basic feature, most editors have...
Comment 17 err 2010-11-25 18:45:16 UTC
Created attachment 103342 [details]
failing test cases

One test fails because canRedo() is false after save.

The other tests investigate state of undoManager after "undo after save". I believe those can be considered as part of this issue report.
Comment 18 err 2010-11-25 18:47:52 UTC
Should have mentioned that these tests came from work on Bug 103467 and Bug 192491
Comment 19 mikato 2010-12-07 21:19:26 UTC
I really would like this implemented as well.  I came from using a pretty simple programming text editor - Crimson Editor - and had a fun surprise after I tried doing this for the first time in NetBeans and it didn't work.

Here's what happened in my case if you need a real world example - you edit a file, then realize you'd rather save the changes in a new file but you already saved.  So you undo back to the original point and save.  Then you redo back to current and save as a new file.  It's really handy and can be a time saver when you can use the undo/redo in that way.

About Crimson Editor - although it's a basic editor with tiny footprint, it really works well and does several things better in the UI that NetBeans could adapt, particularly with Find/Replace functionality and general editing like indenting existing lines and placing of curly brackets.  I'd like to say more about that but this is a bug report.
Comment 20 shiroamada 2011-04-13 06:51:00 UTC
any idea when will this fixed? more than 9 years bug..
Comment 21 bkuberek 2011-04-19 15:20:29 UTC
I am adding my vote hoping this will be fixed. I am using Netbeans 7 and is still a problem. It is very dangerous and although I love Netbeans it is frustrating that I cannot undo something and save it unless I copy and paste that into another text editor first..
Comment 22 Marian Mirilovic 2011-08-02 05:33:44 UTC
>20 dups + votes -> P1 based on http://wiki.netbeans.org/BugPriorityGuidelines
Comment 23 David Strupl 2011-09-21 17:43:36 UTC
P2 still targeted for 7.1 final (not for beta).
Comment 24 Miloslav Metelka 2011-11-08 15:33:21 UTC
I have a working solution (diff attached) but I still have 30 tests failing in openide.text (160 tests pass). I have resolved several failures but it's very slow for me since sometimes I do not fully understand why a particular test asserts certain rather specific things. I'll talk to Yarda regarding the tests.
Comment 25 Miloslav Metelka 2011-11-08 15:34:30 UTC
Created attachment 113004 [details]
Redo after Save diff (30 failing tests)
Comment 26 mikato 2011-11-09 21:05:05 UTC
Hey that makes me happy! I'll be watching to update the moment it's out.
Comment 27 Miloslav Metelka 2011-11-10 13:53:32 UTC
It should now be complete.
There's a new UndoRedoManager implementation that supports redo after save and allows for save actions (such as trailing whitespace removal).
The 196 openide.text tests pass. I have fixed NbEditorLikeKit.Doc implementation to notify VetoableChangeListener before acquiring writeLock().
I have inherited tests from openide.text into editor module to verify BaseDocument operation with the openide.text (there were some inherited openide.text tests this way already).
Although I tried to keep Ernie's grouping undo manager separate during making the undo grouping tests to pass it was becoming more and more complex so in the end I have merged the grouping undo manager into UndoRedoManager.

http://hg.netbeans.org/jet-main/rev/11f80032f91d
Comment 28 zombat 2011-11-10 18:21:58 UTC
That is exciting news!  Personally, I appreciate the effort on this bug, it is my one major complaint with Netbeans.  I look forward to seeing it released.

It's a shame though... another four months and this bug would have been open for a decade.  :D
Comment 29 athompson 2011-11-10 18:40:26 UTC
Although this bug has been open for almost a decade, IIRC for a stretch of a year or three redo did work properly .  Then it reverted back at some point.
Comment 30 Quality Engineering 2011-11-11 15:39:01 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/11f80032f91d
User: Miloslav Metelka <mmetelka@netbeans.org>
Log: #21237 - Redo should be possible after save.
Comment 31 Michel Graciano 2011-11-11 15:40:24 UTC
I have tried it and I faced a exception [1]. Probably related...

[1] http://statistics.netbeans.org/analytics/detail.do?id=182826
Comment 32 athompson 2011-11-11 16:55:29 UTC
(In reply to comment #31)
> I have tried it and I faced a exception [1]. Probably related...
> 
> [1] http://statistics.netbeans.org/analytics/detail.do?id=182826

Did you build Netbeans yourself?  The fix was just integrated today, so AFAIK it won't be available until tomorrow's build.
Comment 33 Michel Graciano 2011-11-11 17:13:13 UTC
Yes, I built it myself earlier today from main repo. I will update this later and retest it, maybe it is already fixed.

Product Version: NetBeans IDE Dev (Build 20111111-898b85081926)
Java: 1.7.0_01; Java HotSpot(TM) Client VM 21.1-b02
System: Linux version 2.6.32-35-generic-pae running on i386; ISO-8859-1; en_US (nb)
Comment 34 Jan Peska 2011-11-14 09:46:00 UTC
I'm sorry, but I have to reopen this. Changes in CloneableEditorSupport.getUndoRedo method caused http://netbeans.org/bugzilla/show_bug.cgi?id=204963

This method returns only instances of new UndoRedoManager, other classes which extend from UndoRedo.Manager are ignored. For *.properties files there is UndoRedo manager to handle edits of multiple files (Context menu/Open). 

I'm afraid similar problems could have any other component with its own UndoRedo manager.
Comment 35 Miloslav Metelka 2011-11-14 18:02:38 UTC
Issue #204963 is fixed.
Comment 36 Jiri Prox 2011-11-24 15:10:33 UTC
verified
Comment 37 err 2011-11-30 15:36:43 UTC
Created attachment 113663 [details]
Additional tests

All the old tests I had passed and are now in this patch.

The patch introduces a new file, UndoRedoAfterSaveTest.java, which is a cleaned up version of the "failing test cases" attachment which I've obsoleted.

The patch also un-comments some checks in UndoRedoWrappingCooperationTest.java which is the original tests for grouping.