]> git.lyx.org Git - lyx.git/blobdiff - src/Cursor.cpp
* LaTeXFeatures.cpp (getI18nPreamble):
[lyx.git] / src / Cursor.cpp
index 266938a2d9b341fd86f552dab9b43d07a535a118..6144d5c28e8cff682db9808efdc0ffa0bea1a35b 100644 (file)
@@ -522,7 +522,7 @@ void Cursor::setCursorToAnchor()
 
 void Cursor::markEditPosition()
 {
-       if (inTexted() && new_word_.empty()) {
+       if (lyxrc.spellcheck_continuously && inTexted() && new_word_.empty()) {
                FontSpan ow = locateWord(WHOLE_WORD);
                if (ow.size() == 1) {
                        LYXERR(Debug::DEBUG, "start new word: "
@@ -547,12 +547,21 @@ void Cursor::clearNewWordPosition()
 
 void Cursor::checkNewWordPosition()
 {
-       if (new_word_.empty())
+       if (!lyxrc.spellcheck_continuously || new_word_.empty())
                return ;
        if (!inTexted())
                clearNewWordPosition();
        else {
-               if (pit() != new_word_.pit())
+               // forget the position of the current new word if
+               // 1) the paragraph changes or
+               // 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);
@@ -2268,6 +2277,7 @@ bool Cursor::fixIfBroken()
        bool const broken_anchor = anchor_.fixIfBroken();
        
        if (broken_cursor || broken_anchor) {
+               clearNewWordPosition();
                clearSelection();
                return true;
        }