rem: r.setEndAfter(left); r.collapse(false); 
add: range.setEndAfter(left); range.collapse(false); 
context: HTMLArea.prototype._checkInsertP = function() {	this.focusEditor();	var i, SC, left, right, r2,		sel   = this._getSelection(),		r     = this._createRange(sel),		p     = this.getAllAncestors(),		block = null,		a = null,		doc   = this._doc,		body  = doc.body;	for (i = 0; i < p.length; ++i) {		if (HTMLArea.isBlockElement(p[i]) && !/html|body|table|tbody|tr/i.test(p[i].tagName)) {			block = p[i];			break;		}	}	if (!r.collapsed) r.deleteContents();	if (HTMLArea.is_safari) sel.empty();		else sel.removeAllRanges();	SC = r.startContainer;	if (HTMLArea.is_opera && SC.nodeType == 3 && SC.data.length == 0) SC = HTMLArea.getPrevNode(SC);	if (!block || /^(td|div)$/i.test(block.tagName)) {		left = SC;		for (i = SC; i && !HTMLArea.isBlockElement(i); i = HTMLArea.getPrevNode(i)) { left = i; }		right = SC;		if (HTMLArea.is_opera && right.nodeType == 3 && right.data.length == 0) right = HTMLArea.getNextNode(right);		if(left != body && right != body && !(block && left == block ) && !(block && right == block )) {			r2 = r.cloneRange();			if (HTMLArea.is_opera) r2.setStart(left,0);				else r2.setStartBefore(left);			r2.surroundContents(block = doc.createElement('p'));			if (!/\S/.test(HTMLArea.getInnerText(block))) {					// Remove any anchor created empty				a = block.lastChild;				if (a && /^a$/i.test(a.tagName) && !/\S/.test(a.innerHTML)) HTMLArea.removeFromParent(a);				block.appendChild(doc.createElement('br'));			}			block.normalize();			if (HTMLArea.is_opera) {				SC = HTMLArea.getNextNode(block);				for (i = SC; i && !HTMLArea.isBlockElement(i); i = HTMLArea.getNextNode(i)) { right = i; }				r.setStart(SC, 0);				r.setEnd(right, right.length);			} else {				r.setEndAfter(right);			}			r.surroundContents(block = doc.createElement('p'));					// Remove any anchor created empty			a = block.previousSibling;			if (a && /^a$/i.test(a.tagName) && !/\S/.test(a.innerHTML)) HTMLArea.removeFromParent(a);			if (!/\S/.test(HTMLArea.getInnerText(block))) {					// Remove any anchor created empty				a = block.lastChild;				if (a && /^a$/i.test(a.tagName) && !/\S/.test(a.innerHTML)) HTMLArea.removeFromParent(a);				block.appendChild(doc.createElement('br'));			}			block.normalize();		} else {			if (!block) block = body;			r = doc.createRange();			r.setStart(block, 0);			r.setEnd(block, 0);			r.insertNode(block = doc.createElement('p'));			block.appendChild(doc.createElement('br'));		}		if (HTMLArea.is_opera) r.selectNode(block);			else r.selectNodeContents(block);	} else {		if (!HTMLArea.is_opera || /\S/.test(HTMLArea.getInnerText(block))) r.setEndAfter(block);		var df = r.extractContents(), left_empty = false;		if(!/\S/.test(HTMLArea.getInnerText(block))) {			block.innerHTML = "<br />";			left_empty = true;		}		p = df.firstChild;		if (p) {			if(!/\S/.test(HTMLArea.getInnerText(p))) { 				if (/^h[1-6]$/i.test(p.tagName)) p = this.convertNode(p,"p");				p.innerHTML = "<br />";			}			if(/^li$/i.test(p.tagName) && left_empty && !block.nextSibling) {				left = block.parentNode;				left.removeChild(block);				r.setEndAfter(left);				r.collapse(false);				p = this.convertNode(p, /^li$/i.test(left.parentNode.tagName) ? "br" : "p");			}			r.insertNode(df);				// Remove any anchor created empty			var a = p.previousSibling.lastChild;			if (a && /^a$/i.test(a.tagName) && !/\S/.test(a.innerHTML)) HTMLArea.removeFromParent(a);			if (HTMLArea.is_opera) r.selectNode(p);				else r.selectNodeContents(p);		}	}	r.collapse(true);	if (HTMLArea.is_safari) sel.setBaseAndExtent(r.startContainer,r.startOffset,r.endContainer,r.endOffset);		else sel.addRange(r);	this.scrollToCaret();};
meta: 9100	/local1/tlutelli/issta_data/temp/all_js/javascript/2007_temp/2007/9100/61e87e9a1146c16b85803b3af1958aafd4d4dd8a/htmlarea-gecko.js/buggy/typo3/sysext/rtehtmlarea/htmlarea/htmlarea-gecko.js