tuliob / jsyntaxpane

Automatically exported from code.google.com/p/jsyntaxpane
0 stars 0 forks source link

Undo grouping doesn't include first action in the chain #124

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Type a word fast in the editor, for example "testing".
2. Press Ctrl+Z to undo.
3. "esting" will be deleted, but the "t" will remain.

I think undo grouping generally works OK (despite issue 88), except for 
this problem. It seems that the first action in a group is not added to a 
compound undoable action. I think it is highly probable that this is the 
main reason behind the perceived "unintuitiveness" of undos reported in 
issue 88, but I don't report it there since this is more specific and 
perhaps the reporter of issue 88 would still want more improvements.

Off the top of my head, I think the following fix would work (too late in 
the night to test it now):

in CompoundUndoManager, change this:

        if (comp == null) {
            comp = new CompoundEdit();
        }

To this:

        if (comp == null) {
            comp = new CompoundEdit();
            startMillis = now;
        }

Note that with the current code, if the last action performed was a long 
enough time ago, you create a new CompoundEdit (which is fine) but then you 
enter the if (now - startMillis > IDLE_DELAY_MS) block (since you haven't 
refreshed startMillis yet by that time), and this makes you immediately END 
the compound edit, causing the bug. With the added line you trivially 
prevent this without any side effects.

Original issue reported on code.google.com by komoku on 8 Nov 2009 at 1:16

GoogleCodeExporter commented 9 years ago
Hmm.. The change seem to work for this instance.  I'll see if it sorts out some 
other
issues.

Thanks a million!

Original comment by ayman.al...@gmail.com on 8 Nov 2009 at 6:18

GoogleCodeExporter commented 9 years ago
I did more changes in r117.  Will create a binary download shortly.

See issue 88

Original comment by ayman.al...@gmail.com on 8 Nov 2009 at 10:19

GoogleCodeExporter commented 9 years ago
That's really great. Thanks for the quick reaction and for this nice project, 
it's  
very useful to me. I hope Issue 113 is also fixed in the new binary, that one 
would 
be nice too :)

Original comment by komoku on 8 Nov 2009 at 10:37