]> git.lyx.org Git - lyx.git/blobdiff - src/Cursor.cpp
Fix typo.
[lyx.git] / src / Cursor.cpp
index c1eb32f684b34876766c5016ee10752821c0b910..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;
@@ -1043,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) {
@@ -1947,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:
@@ -2424,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();
 }