X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/e3daf6a78b558bb2d776b389ba65a58eea1de2be..b264c171a5885976ef8f077be37e7cc83bf8a0fd:/project/static/js/lib/codemirror/select.js diff --git a/project/static/js/lib/codemirror/select.js b/project/static/js/lib/codemirror/select.js index 002004e2..d513ba5f 100644 --- a/project/static/js/lib/codemirror/select.js +++ b/project/static/js/lib/codemirror/select.js @@ -238,7 +238,7 @@ var select = {}; // Move the start of a range to the start of a node, // compensating for the fact that you can't call // moveToElementText with text nodes. - function moveToNodeStart(range, node) { + function moveToNodeStart(range, node) { if (node.nodeType == 3) { var count = 0, cur = node.previousSibling; while (cur && cur.nodeType == 3) { @@ -247,19 +247,19 @@ var select = {}; } if (cur) { try{range.moveToElementText(cur);} - catch(e){alert(cur + " " + cur.nodeType + " " + (cur && cur.outerHTML));} + catch(e){} range.collapse(false); } else range.moveToElementText(node.parentNode); if (count) range.move("character", count); } - else try{range.moveToElementText(node);} catch(e) {}; + else range.moveToElementText(node); } // Do a binary search through the container object, comparing // the start of each node to the selection - var start = 0, end = container.childNodes.length; - while (start != end) { + var start = 0, end = container.childNodes.length - 1; + while (start < end) { var middle = Math.ceil((end + start) / 2), node = container.childNodes[middle]; if (!node) return false; // Don't ask. IE6 manages this sometimes. moveToNodeStart(range2, node);