Author: zooey Date: 2010-08-10 16:02:22 +0200 (Tue, 10 Aug 2010) New Revision: 38006 Changeset: http://dev.haiku-os.org/changeset/38006 Ticket: http://dev.haiku-os.org/ticket/5959 Modified: haiku/trunk/src/kits/interface/TextView.cpp Log: Closing #5959: * _DoInsertText() must not assume that the text is actually being inserted by InsertText(), since that's a virtual method meant to be overridden by subclasses. So the updating of caret-position and selection start/end has to happen in InsertText(). Modified: haiku/trunk/src/kits/interface/TextView.cpp =================================================================== --- haiku/trunk/src/kits/interface/TextView.cpp 2010-08-10 13:58:19 UTC (rev 38005) +++ haiku/trunk/src/kits/interface/TextView.cpp 2010-08-10 14:02:22 UTC (rev 38006) @@ -3039,6 +3039,12 @@ // update the style runs fStyles->BumpOffset(inLength, fStyles->OffsetToRun(inOffset - 1) + 1); + + // offset the caret/selection, if the text was inserted before it + if (inOffset <= fSelEnd) { + fSelStart += inLength; + fCaretOffset = fSelEnd = fSelStart; + } } if (fStylable && inRuns != NULL) { @@ -4202,12 +4208,6 @@ // copy data into buffer InsertText(inText, inLength, inOffset, inRuns); - // offset the caret/selection, if the text was inserted before it - if (inOffset <= fSelEnd) { - fSelStart += inLength; - fCaretOffset = fSelEnd = fSelStart; - } - // recalc line breaks and draw the text _Refresh(inOffset, inOffset + inLength, false); }