Index: /FCKeditor/trunk/editor/_source/internals/fck_gecko.js
===================================================================
--- /FCKeditor/trunk/editor/_source/internals/fck_gecko.js	(revision 596)
+++ /FCKeditor/trunk/editor/_source/internals/fck_gecko.js	(revision 597)
@@ -65,6 +65,8 @@
 
 		var keyCode = evt.keyCode ;
-		var modKeys = { 34 : 1, 35 : 1, 39 : 1, 40 : 1 } ;
-		if ( ! modKeys[keyCode] )
+		// ignore if positioning key is not pressed.
+		// left or up arrow keys need to be processed as well, since <a> links can be expanded in Gecko's editor
+		// when the caret moved left or up from another block element below.
+		if ( keyCode < 33 || keyCode > 40 )
 			return ;
 
@@ -78,4 +80,5 @@
 			var node = range.endContainer ;
 			
+			// only perform the patched behavior if we're at the end of a text node.
 			if ( node.nodeType != 3 )
 				return ;
@@ -84,5 +87,10 @@
 				return ;
 
-			// we've moved to just after the last character of a text node under an unknown tag, how to proceed?
+			// only perform the patched behavior if we're in an <a> tag, or the End key is pressed.
+			var parentTag = node.parentNode.tagName.toLowerCase() ;
+			if ( ! (  parentTag == 'a' || ( ! FCKListsLib.BlockElements[parentTag] && keyCode == 35 ) ) )
+				return ;
+
+			// our caret has moved to just after the last character of a text node under an unknown tag, how to proceed?
 			// first, see if there are other text nodes by DFS walking from this text node.
 			// 	- if the DFS has scanned all nodes under my parent, then go the next step.
@@ -108,5 +116,7 @@
 				// no suitable next siblings under our grandparent! what to do next?
 				node = node.parentNode ;
-				if ( FCKListsLib.BlockElements[ node.tagName.toLowerCase() ] || node == FCK.EditorDocument.body )
+				if ( FCKListsLib.BlockElements[ parentTag ] 
+						|| FCKListsLib.EmptyElements[ parentTag ]
+						|| node == FCK.EditorDocument.body )
 				{
 					// if our parent is a block node, move to the end of our parent.
@@ -116,9 +126,32 @@
 				else
 				{
-					// if our parent is not a block node, move to the end of our grandparent.
+					// things are a little bit more interesting if our parent is not a block node
+					// due to the weired ways how Gecko's caret acts...
+
+					var stopNode = node.nextSibling ;
+
+					// find out the next block/empty element at our grandparent, we'll 
+					// move the caret just before it.
+					while ( stopNode )
+					{
+						if ( stopNode.nodeType != 1 )
+						{
+							stopNode = stopNode.nextSibling ;
+							continue ;
+						}
+						
+						var stopTag = stopNode.tagName.toLowerCase() ;
+						if ( FCKListsLib.BlockElements[stopTag] || FCKListsLib.EmptyElements[stopTag] )
+							break ;
+						stopNode = stopNode.nextSibling ;
+					}
+
 					// note that the dummy marker below is NEEDED, otherwise the caret's behavior will 
 					// be broken in Gecko.
 					var marker = FCK.EditorDocument.createTextNode( "" ) ;
-					node.parentNode.appendChild( marker ) ;
+					if ( stopNode )
+						node.parentNode.insertBefore( marker, stopNode ) ;
+					else
+						node.parentNode.appendChild( marker ) ;
 					range.setStart( marker, 0 ) ;
 					range.setEnd( marker, 0 ) ;
