From 5866504abad6caa6ab01c0c66044caae650b4206 Mon Sep 17 00:00:00 2001 From: Stephan Witt Date: Tue, 15 Mar 2011 10:27:41 +0000 Subject: [PATCH] #7350 more checks to validate the DocIterator before calling locateWord() in checkNewWordPosition() git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37931 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Cursor.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Cursor.cpp b/src/Cursor.cpp index 85b3d9857f..6144d5c28e 100644 --- a/src/Cursor.cpp +++ b/src/Cursor.cpp @@ -552,10 +552,16 @@ void Cursor::checkNewWordPosition() 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 Cursor::fixIfBroken() bool const broken_anchor = anchor_.fixIfBroken(); if (broken_cursor || broken_anchor) { + clearNewWordPosition(); clearSelection(); return true; } -- 2.39.5