starmath/source/cursor.cxx |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

New commits:
commit f045d14791a84f478c40fbd6b0590f527b36cbff
Author: Takeshi Abe <t...@fixedpoint.jp>
Date:   Thu Jul 21 17:57:28 2016 +0900

    starmath: Return early if the cursor locates after a text node
    
    No longer create unnecessary copy of nodes.
    
    Change-Id: Icf8cdd3ce0f9ebbf7159e9e7eaea7abe52c05060
    Reviewed-on: https://gerrit.libreoffice.org/27366
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Takeshi Abe <t...@fixedpoint.jp>

diff --git a/starmath/source/cursor.cxx b/starmath/source/cursor.cxx
index bef900a..b1ef0b0 100644
--- a/starmath/source/cursor.cxx
+++ b/starmath/source/cursor.cxx
@@ -354,16 +354,17 @@ SmNodeList::iterator 
SmCursor::FindPositionInLineList(SmNodeList* pLineList,
                 if(rCaretPos.Index > 0)
                 {
                     SmTextNode* pText = 
static_cast<SmTextNode*>(rCaretPos.pSelectedNode);
+                    if (rCaretPos.Index == pText->GetText().getLength())
+                        return ++it;
                     OUString str1 = pText->GetText().copy(0, rCaretPos.Index);
                     OUString str2 = pText->GetText().copy(rCaretPos.Index);
                     pText->ChangeText(str1);
                     ++it;
                     //Insert str2 as new text node
-                    if(!str2.isEmpty()){
-                        SmTextNode* pNewText = new 
SmTextNode(pText->GetToken(), pText->GetFontDesc());
-                        pNewText->ChangeText(str2);
-                        it = pLineList->insert(it, pNewText);
-                    }
+                    assert(!str2.isEmpty());
+                    SmTextNode* pNewText = new SmTextNode(pText->GetToken(), 
pText->GetFontDesc());
+                    pNewText->ChangeText(str2);
+                    it = pLineList->insert(it, pNewText);
                 }
             }else
                 ++it;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to