From e70da3e14ca84e8f0e40f141a441be4dada34265 Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Tue, 10 Aug 2010 14:02:22 +0000 Subject: [PATCH] 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(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38006 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/TextView.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/kits/interface/TextView.cpp b/src/kits/interface/TextView.cpp index f26330ceba..126f21e9d9 100644 --- a/src/kits/interface/TextView.cpp +++ b/src/kits/interface/TextView.cpp @@ -3039,6 +3039,12 @@ BTextView::InsertText(const char *inText, int32 inLength, int32 inOffset, // 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 @@ BTextView::_DoInsertText(const char *inText, int32 inLength, int32 inOffset, // 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); }