Index: /FCKeditor/trunk/editor/_source/classes/fckdomrange.js
===================================================================
--- /FCKeditor/trunk/editor/_source/classes/fckdomrange.js	(revision 1077)
+++ /FCKeditor/trunk/editor/_source/classes/fckdomrange.js	(revision 1078)
@@ -441,9 +441,16 @@
 			"End" : [ this._Range.endOffset ]
 		} ;
+		// Since we're treating the document tree as normalized, we need to backtrack the text lengths
+		// of previous text nodes into the offset value.
 		var curStart = this._Range.startContainer.previousSibling ;
 		var curEnd = this._Range.endContainer.previousSibling ;
+
+		// Also note that the node that we use for "address base" would change during backtracking.
+		var addrStart = this._Range.startContainer ;
+		var addrEnd = this._Range.endContainer ;
 		while ( curStart && curStart.nodeType == 3 )
 		{
 			bookmark.Start[0] += curStart.length ;
+			addrStart = curStart ;
 			curStart = curStart.previousSibling ;
 		}
@@ -451,10 +458,11 @@
 		{
 			bookmark.End[0] += curEnd.length ;
+			addrEnd = curEnd ;
 			curEnd = curEnd.previousSibling ;
 		}
 		// Then, we record down the precise position of the container nodes
 		// by walking up the DOM tree and counting their childNode index
-		bookmark.Start = FCKDomTools.GetNodeAddress( this._Range.startContainer, true ).concat( bookmark.Start ) ;
-		bookmark.End = FCKDomTools.GetNodeAddress( this._Range.endContainer, true ).concat( bookmark.End ) ;
+		bookmark.Start = FCKDomTools.GetNodeAddress( addrStart, true ).concat( bookmark.Start ) ;
+		bookmark.End = FCKDomTools.GetNodeAddress( addrEnd, true ).concat( bookmark.End ) ;
 		return bookmark;
 	},
Index: /FCKeditor/trunk/editor/dialog/fck_replace.html
===================================================================
--- /FCKeditor/trunk/editor/dialog/fck_replace.html	(revision 1077)
+++ /FCKeditor/trunk/editor/dialog/fck_replace.html	(revision 1078)
@@ -104,21 +104,43 @@
 function GetData( bookmark )
 {
-	var currentNode = oEditor.FCK.EditorDocument.documentElement;
-	for( var i = 0 ; i < bookmark.length ; i++ )
-	{
-		if ( currentNode.childNodes.length > bookmark[i] )
-			currentNode = currentNode.childNodes.item( bookmark[i] ) ;
-		else if ( currentNode.nodeType == 3 )	// text node
+	var cursor = oEditor.FCK.EditorDocument.documentElement ;
+	for ( var i = 0 ; i < bookmark.length ; i++ )
+	{
+		var target = bookmark[i] ;
+		var currentIndex = -1 ;
+		if ( cursor.nodeType != 3 )
 		{
-			var c = currentNode.nodeValue.charAt( bookmark[i] ) ;
-			if ( i == bookmark.length - 1 )
-				return c != "" ? c : null ;
-			else
+			for (var j = 0 ; j < cursor.childNodes.length ; j++ )
+			{
+				var candidate = cursor.childNodes[j] ;
+				if ( candidate.nodeType == 3 &&
+						candidate.previousSibling &&
+						candidate.previousSibling.nodeType == 3 )
+					continue ;
+				currentIndex++ ;
+				if ( currentIndex == target )
+				{
+					cursor = candidate ;
+					break ;
+				}
+			}
+			if ( currentIndex < target )
 				return null ;
 		}
 		else
-			return null;
-	}
-	return currentNode ;
+		{
+			if ( i != bookmark.length - 1 )
+				return null ;
+			while ( target >= cursor.length && cursor.nextSibling && cursor.nextSibling.nodeType == 3 )
+			{
+				target -= cursor.length ;
+				cursor = cursor.nextSibling ;
+			}
+			cursor = cursor.nodeValue.charAt( target ) ;
+			if ( cursor == "" )
+				cursor = null ;
+		}
+	}
+	return cursor ;
 }
 
@@ -128,5 +150,4 @@
 	// See if there's anything further down the tree.
 	var next = bookmark.concat( [0] ) ;
-
 	if ( GetData( next ) != null )
 		return next ;
