--- takahashi.xul 2006/06/10 15:03:44 10 +++ takahashi.xul 2006/06/10 15:20:43 11 @@ -1099,9 +1099,18 @@ insertTextFor : function(aString, aNode, aPosOffset) { var pos = aNode.selectionStart; + var sel_len = aNode.selectionEnd - aNode.selectionStart; var value = aNode.value; - aNode.value = [value.substring(0, pos), aString, value.substring(pos, value.length)].join(''); - aNode.selectionEnd = aNode.selectionStart = pos + (aPosOffset || 0); + if (! aPosOffset) aPosOffset = 0; + aNode.value = [ + value.substring(0, pos), + aString.substring(0,aPosOffset), + value.substring(pos, pos + sel_len), + aString.substring(aPosOffset, aString.length), + value.substring(pos + sel_len, value.length - sel_len) + ].join(''); + aNode.selectionStart = pos + (aPosOffset || 0); + aNode.selectionEnd = aNode.selectionStart + sel_len; },