Index: /FCKeditor/trunk/editor/_source/classes/fckenterkey.js
===================================================================
--- /FCKeditor/trunk/editor/_source/classes/fckenterkey.js	(revision 397)
+++ /FCKeditor/trunk/editor/_source/classes/fckenterkey.js	(revision 398)
@@ -259,5 +259,4 @@
 	// Save an undo snapshot before doing anything
 	// This is to conform with the behavior seen in MS Word
-	FCKUndo.Changed = 1;
 	FCKUndo.SaveUndoStep();
 
Index: /FCKeditor/trunk/editor/_source/commandclasses/fck_othercommands.js
===================================================================
--- /FCKeditor/trunk/editor/_source/commandclasses/fck_othercommands.js	(revision 397)
+++ /FCKeditor/trunk/editor/_source/commandclasses/fck_othercommands.js	(revision 398)
@@ -263,4 +263,7 @@
 FCKPageBreakCommand.prototype.Execute = function()
 {
+	// Take an undo snapshot before changing the document
+	FCKUndo.SaveUndoStep();
+
 //	var e = FCK.EditorDocument.createElement( 'CENTER' ) ;
 //	e.style.pageBreakAfter = 'always' ;
@@ -289,4 +292,7 @@
 FCKUnlinkCommand.prototype.Execute = function()
 {
+	// Take an undo snapshot before changing the document
+	FCKUndo.SaveUndoStep();
+
 	if ( FCKBrowserInfo.IsGecko )
 	{
@@ -384,4 +390,5 @@
 	Execute : function()
 	{
+		FCKUndo.SaveUndoStep();
 		FCK.InsertElement( 'hr' ) ;
 	},
Index: /FCKeditor/trunk/editor/_source/internals/fck.js
===================================================================
--- /FCKeditor/trunk/editor/_source/internals/fck.js	(revision 397)
+++ /FCKeditor/trunk/editor/_source/internals/fck.js	(revision 398)
@@ -713,5 +713,4 @@
 		else if ( keystrokeValue == 'CustomCut' )
 		{
-			FCKUndo.Changed = 1;
 			FCKUndo.SaveUndoStep();
 			return false;
Index: /FCKeditor/trunk/editor/_source/internals/fck_gecko.js
===================================================================
--- /FCKeditor/trunk/editor/_source/internals/fck_gecko.js	(revision 397)
+++ /FCKeditor/trunk/editor/_source/internals/fck_gecko.js	(revision 398)
@@ -41,15 +41,30 @@
 	{
 		FCKUndo.TypesCount = 0 ;
-		FCKUndo.Changed = 0;
 		FCKUndo.SaveUndoStep() ;
 	}
 }
 
+FCK._IsFunctionKey = function(keyCode)
+{
+	// keys that are captured but do not change editor contents
+	if (keyCode >= 16 && keyCode <= 20)
+		// shift, ctrl, alt, pause, capslock
+		return true;
+	if (keyCode == 27 || (keyCode >= 33 && keyCode <= 40))
+		// esc, page up, page down, end, home, left, up, right, down
+		return true;
+	if (keyCode == 45)
+		// insert, no effect on FCKeditor, yet
+		return true;
+	return false;
+}
+
 FCK._KeyDownListener = function( evt )
 {
 	if ( FCK.EditorWindow )
 	{
-		if ( !( evt.keyCode >= 16 && evt.keyCode <= 46 ) // do not capture function key presses, like arrow keys or shift/alt/ctrl
-			&& !(evt.ctrlKey || evt.metaKey) ) // do not capture Ctrl hotkeys, as they have their snapshot capture logic
+		if ( !FCK._IsFunctionKey(evt.keyCode) // do not capture function key presses, like arrow keys or shift/alt/ctrl
+			&& !(evt.ctrlKey || evt.metaKey) // do not capture Ctrl hotkeys, as they have their snapshot capture logic
+			&& !(evt.keyCode == 46) ) // do not capture Del, it has its own capture logic in fckenterkey.js
 			FCK._KeyDownUndo();
 	}
@@ -161,6 +176,4 @@
 FCK.Paste = function()
 {
-	FCKUndo.Changed = 1;
-
 	// Save a snapshot for undo before actually paste the text
 	FCKUndo.SaveUndoStep();
Index: /FCKeditor/trunk/editor/_source/internals/fckundo_gecko.js
===================================================================
--- /FCKeditor/trunk/editor/_source/internals/fckundo_gecko.js	(revision 397)
+++ /FCKeditor/trunk/editor/_source/internals/fckundo_gecko.js	(revision 398)
@@ -19,5 +19,5 @@
  * == END LICENSE ==
  *
- * Fake implementation to ignore calls on Gecko.
+ * Gecko specific implementation for the Undo/Redo system.
  */
 
@@ -27,5 +27,5 @@
 FCKUndo.CurrentIndex = -1 ;
 FCKUndo.TypesCount = 0 ;
-FCKUndo.Changed = false ;
+FCKUndo.Changed = false ;	// Is the document changed in respect to its initial image?
 FCKUndo.MaxTypes = 25 ;
 FCKUndo.Typing = false;
@@ -36,5 +36,10 @@
 		return ;
 
-	// Get the bookmarked HTML.
+	// Assume the editor content is changed when SaveUndoStep() is called after the first time.
+	// This also enables the undo button in toolbar.
+	if (FCKUndo.SavedData.length)
+		FCKUndo.Changed = true;
+
+	// Get the HTML content.
 	var sHtml = FCK.EditorDocument.body.innerHTML ;
 
@@ -128,5 +133,16 @@
 	{
 		range.MoveToBookmark2(bookmark);
-		range.Select();
+		try
+		{
+			// this does not always succeed, there are still some tricky cases where it fails
+			// e.g. add a special character at end of document, undo, redo -> error
+			range.Select();
+		}
+		catch (e)
+		{
+			// if select restore fails, put the caret at the end of the document
+			range.MoveToPosition(FCK.EditorDocument.body, 4);
+			range.Select();
+		}
 	}
 
Index: /FCKeditor/trunk/editor/dialog/fck_image/fck_image.js
===================================================================
--- /FCKeditor/trunk/editor/dialog/fck_image/fck_image.js	(revision 397)
+++ /FCKeditor/trunk/editor/dialog/fck_image/fck_image.js	(revision 398)
@@ -219,4 +219,5 @@
 	}
 
+	oEditor.FCKUndo.SaveUndoStep() ;
 	if ( !bHasImage )
 	{
@@ -230,6 +231,4 @@
 			oImage = FCK.InsertElement( 'img' ) ;
 	}
-	else
-		oEditor.FCKUndo.SaveUndoStep() ;
 
 	UpdateImage( oImage ) ;
Index: /FCKeditor/trunk/editor/dialog/fck_smiley.html
===================================================================
--- /FCKeditor/trunk/editor/dialog/fck_smiley.html	(revision 397)
+++ /FCKeditor/trunk/editor/dialog/fck_smiley.html	(revision 398)
@@ -46,4 +46,5 @@
 function InsertSmiley( url )
 {
+	oEditor.FCKUndo.SaveUndoStep();
 	var oImg = oEditor.FCK.InsertElement( 'img' ) ;
 	oImg.src = url ;
Index: /FCKeditor/trunk/editor/dialog/fck_specialchar.html
===================================================================
--- /FCKeditor/trunk/editor/dialog/fck_specialchar.html	(revision 397)
+++ /FCKeditor/trunk/editor/dialog/fck_specialchar.html	(revision 398)
@@ -42,4 +42,5 @@
 function insertChar(charValue)
 {
+	oEditor.FCKUndo.SaveUndoStep();
 	oEditor.FCK.InsertHtml( charValue || "" ) ;
 	window.parent.Cancel() ;
