]> git.lyx.org Git - lyx.git/blobdiff - src/Cursor.cpp
Fix typo.
[lyx.git] / src / Cursor.cpp
index c1458dc8a7a0cfc757870775cb2095e748ede087..8cc62634a9a04912ed1d51069e371ec878ffffad 100644 (file)
@@ -550,8 +550,11 @@ int Cursor::currentMode()
 
 bool Cursor::inCoordCache() const
 {
+       // the root inset is not in cache, but we do not need it.
+       if (depth() == 1)
+               return true;
        CoordCache::Insets const & icache = bv_->coordCache().getInsets();
-       for (size_t i = 0 ; i < depth() ; ++i)
+       for (size_t i = 1 ; i < depth() ; ++i)
                if (!icache.has(&(*this)[i].inset()))
                        return false;
        return true;
@@ -744,10 +747,7 @@ bool Cursor::posVisRight(bool skip_inset)
 
        }
 
-       bool moved = (new_cur.pos() != pos()
-                                 || new_cur.pit() != pit()
-                                 || new_cur.boundary() != boundary()
-                                 || &new_cur.inset() != &inset());
+       bool const moved = new_cur != *this || new_cur.boundary() != boundary();
 
        if (moved) {
                LYXERR(Debug::RTL, "moving to: " << new_cur.pos()
@@ -843,9 +843,7 @@ bool Cursor::posVisLeft(bool skip_inset)
 
        }
 
-       bool moved = (new_cur.pos() != pos()
-                                 || new_cur.pit() != pit()
-                                 || new_cur.boundary() != boundary());
+       bool const moved = new_cur != *this || new_cur.boundary() != boundary();
 
        if (moved) {
                LYXERR(Debug::RTL, "moving to: " << new_cur.pos()
@@ -1048,8 +1046,11 @@ CursorSlice Cursor::normalAnchor() const
        // LASSERT: There have been several bugs around this code, that seem
        // to involve failures to reset the anchor. We can at least not crash
        // in release mode by resetting it ourselves.
-       LASSERT(anchor_.depth() >= depth(),
-               const_cast<DocIterator &>(anchor_) = *this);
+       if (anchor_.depth() < depth()) {
+               LYXERR0("Cursor is deeper than anchor. PLEASE REPORT.\nCursor is"
+                       << *this);
+               const_cast<DocIterator &>(anchor_) = *this;
+       }
 
        CursorSlice normal = anchor_[depth() - 1];
        if (depth() < anchor_.depth() && top() <= normal) {
@@ -1303,7 +1304,7 @@ void Cursor::plainInsert(MathAtom const & t)
        ++pos();
        inset().setBuffer(bv_->buffer());
        inset().initView();
-       forceBufferUpdate();
+       checkBufferStructure();
 }
 
 
@@ -1952,6 +1953,8 @@ bool Cursor::upDownInText(bool up, bool & updateNeeded)
                        // Make sure that cur gets back whatever happened to dummy (Lgb)
                        operator=(dummy);
                }
+               if (inTexted() && pos() && paragraph().isEnvSeparator(pos() - 1))
+                       posBackward();
        } else {
                // if there is a selection, we stay out of any inset,
                // and just jump to the right position:
@@ -2429,6 +2432,12 @@ void Cursor::checkBufferStructure()
                // In case the master has no gui associated with it,
                // the TocItem is not updated (part of bug 5699).
                buffer()->tocBackend().updateItem(*this);
+
+       // If the last tracked change of the paragraph has just been
+       // deleted, then we need to recompute the buffer flag
+       // tracked_changes_present_.
+       if (inTexted() && paragraph().isChangeUpdateRequired())
+               disp_.forceChangesUpdate();
 }