﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
915	Bugs in JavaScript undo/redo logic of FCKeditor	Martin Kou	Martin Kou	"'''Background:'''
The JavaScript undo/redo logic is used for IE only in the release version (2.4.3), and is being ported to Firefox in the SVN trunk. FCKeditor's current undo/redo logic in JavaScript suffers from a number of critical bugs.


'''- Pressing Ctrl-Z breaks the undo/redo system'''
{{{
1. Open the current release version of FCKeditor in http://www.fckeditor.net/demo in Internet Explorer 6 or 7.
2. Typing some random characters into the editor instance.
3. Press Ctrl-Z to undo, it works.
4. Press Ctrl-Y to redo, it doesn't work.
}}}
{{{
1. Open the current release version of FCKeditor in http://www.fckeditor.net/demo in Internet Explorer 6 or 7.
2. Select the editor instance. Don't type anything yet.
3. Press Ctrl-Z a few times.
4. Type some random characters into the editor instance.
5. Perform undo by either Ctrl-Z or by the toolbar button above, it doesn't work.
}}}
There is obviously a logic error in the current undo/redo JavaScript code. If you print out the ''FCKUndo.CurrentIndex'' counter after the above test cases, you'll see a negative index lower than -1 (say, -15), which should not happen at all considering it's an index to an array. What really happened was that, each time you pressed Ctrl-Z inside of the editor, the ''FCKUndo.CurrentIndex'' was decremented by 1 unconditionally.

'''- Selection is not restored for the first change'''
{{{
1. Open the current release version of FCKeditor in http://www.fckeditor.net/demo in Internet Explorer 6 or 7.
2. Select some text.
3. Change the font size.
4. Press the undo button in toolbar.
5. The font size is restored, but the text selection is not.
}}}
This bug occurs because the current undo/redo logic thinks the snapshot just before the font size change was the same as the initial snapshot taken at editor initialization, so it ignored the newer snapshot. The current logic neglected to check for differences in selection.

'''- No stepwise undo for Cut and Delete operations'''
{{{
1. Open the current release version of FCKeditor in http://www.fckeditor.net/demo in Internet Explorer 6 or 7.
2. Select some text.
3. Press Ctrl-X or Del.
4. Select some more text.
5. Press Ctrl-X or Del.
6. Select even more text.
7. Press Ctrl-X or Del.
8. Press the undo toolbar button.
9. Your three delete/cut operations were restored in one step. Compare this behavior to MS Word 2003, MS Word restored the 3 operations in a stepwise manner. Also compare the how the stepwise undo you got if you did the cut operation by the toolbar button instead.
}}}
This bug occurs because there are currently no registered commands for Ctrl-X or Del keystrokes in FCKeditor. They are treated as simple keyboard input in front of the undo/redo system."	Bug	closed	Normal	FCKeditor 2.5 Beta	Core : Undo & Redo	SVN (FCKeditor) - Retired	fixed		
