Author: switt
Date: Tue Mar 15 11:27:41 2011
New Revision: 37931
URL: http://www.lyx.org/trac/changeset/37931

Log:
#7350 more checks to validate the DocIterator before calling locateWord() in 
checkNewWordPosition()

Modified:
   lyx-devel/trunk/src/Cursor.cpp

Modified: lyx-devel/trunk/src/Cursor.cpp
==============================================================================
--- lyx-devel/trunk/src/Cursor.cpp      Tue Mar 15 10:53:15 2011        (r37930)
+++ lyx-devel/trunk/src/Cursor.cpp      Tue Mar 15 11:27:41 2011        (r37931)
@@ -552,10 +552,16 @@
        if (!inTexted())
                clearNewWordPosition();
        else {
-               // forget the position of the current started word
+               // forget the position of the current new word if
                // 1) the paragraph changes or
-               // 2) the count of nested insets changes
-               if (pit() != new_word_.pit() || depth() != new_word_.depth())
+               // 2) the count of nested insets changes or
+               // 3) the cursor pos is out of paragraph bound
+               if (pit() != new_word_.pit() ||
+                       depth() != new_word_.depth() ||
+                       new_word_.pos() > new_word_.lastpos()) {
+                       clearNewWordPosition();
+               } else if (new_word_.fixIfBroken())
+                       // 4) or the remembered position was "broken"
                        clearNewWordPosition();
                else {
                        FontSpan nw = locateWord(WHOLE_WORD);
@@ -2271,6 +2277,7 @@
        bool const broken_anchor = anchor_.fixIfBroken();
        
        if (broken_cursor || broken_anchor) {
+               clearNewWordPosition();
                clearSelection();
                return true;
        }

Reply via email to