JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.1.1
[ckeditor.git] / _source / core / dom / range.js
index 264ee4e..8d30b4f 100644 (file)
@@ -133,7 +133,7 @@ CKEDITOR.dom.range = function( document )
 \r
                        currentNode = levelStartNode.getNext();\r
 \r
-                       while( currentNode )\r
+                       while ( currentNode )\r
                        {\r
                                // Stop processing when the current node matches a node in the\r
                                // endParents tree or if it is the endNode.\r
@@ -180,7 +180,7 @@ CKEDITOR.dom.range = function( document )
                        {\r
                                currentNode = levelStartNode.getPrevious();\r
 \r
-                               while( currentNode )\r
+                               while ( currentNode )\r
                                {\r
                                        // Stop processing when the current node matches a node in the\r
                                        // startParents tree or if it is the startNode.\r
@@ -252,10 +252,10 @@ CKEDITOR.dom.range = function( document )
                }\r
 \r
                // Cleanup any marked node.\r
-               if( removeStartNode )\r
+               if ( removeStartNode )\r
                        startNode.remove();\r
 \r
-               if( removeEndNode && endNode.$.parentNode )\r
+               if ( removeEndNode && endNode.$.parentNode )\r
                        endNode.remove();\r
        };\r
 \r
@@ -278,7 +278,7 @@ CKEDITOR.dom.range = function( document )
                                if ( CKEDITOR.tools.trim( node.getText() ).length )\r
                                        return false;\r
                                }\r
-                       else if( node.type == CKEDITOR.NODE_ELEMENT )\r
+                       else if ( node.type == CKEDITOR.NODE_ELEMENT )\r
                        {\r
                                // If there are non-empty inline elements (e.g. <img />), then we're not\r
                                // at the start.\r
@@ -742,15 +742,21 @@ CKEDITOR.dom.range = function( document )
 \r
                                        startOffset = startContainer.getIndex() + 1;\r
                                        startContainer = startContainer.getParent();\r
-                                       // Check if it is necessary to update the end boundary.\r
-                                       if ( !collapsed && this.startContainer.equals( this.endContainer ) )\r
+\r
+                                       // Check all necessity of updating the end boundary.\r
+                                       if ( this.startContainer.equals( this.endContainer ) )\r
                                                this.setEnd( nextText, this.endOffset - this.startOffset );\r
+                                       else if ( startContainer.equals( this.endContainer ) )\r
+                                               this.endOffset += 1;\r
                                }\r
 \r
                                this.setStart( startContainer, startOffset );\r
 \r
                                if ( collapsed )\r
+                               {\r
                                        this.collapse( true );\r
+                                       return;\r
+                               }\r
                        }\r
 \r
                        var endContainer = this.endContainer;\r