]> git.lyx.org Git - lyx.git/blobdiff - src/DocIterator.cpp
Try even harder to obtain an instant preview
[lyx.git] / src / DocIterator.cpp
index 6e3775b4e36e8886a53123ddda16948d4a767e06..4dbd2614de2c0045e11cd77ad35ae9ea8b7eb154 100644 (file)
@@ -217,7 +217,7 @@ CursorSlice const & DocIterator::innerTextSlice() const
                if (slices_[i].text())
                        return slices_[i];
 
-       // This case is in principe not possible. We _must_
+       // This case is in principle not possible. We _must_
        // be inside a Text.
        LBUFERR(false);
        // Squash warning
@@ -449,6 +449,28 @@ void DocIterator::backwardPos()
 }
 
 
+#if 0
+// works, but currently not needed
+void DocIterator::backwardInset()
+{
+       backwardPos();
+
+       while (!empty() && !nextInset()) {
+               if (inTexted()) {
+                       pos_type const lastp = lastpos();
+                       Paragraph const & par = paragraph();
+                       pos_type & pos = top().pos();
+                       while (pos > 0 && (pos == lastp || !par.isInset(pos)))
+                               --pos;
+                       if (pos > 0)
+                               break;
+               }
+               backwardPos();
+       }
+}
+#endif
+
+
 bool DocIterator::hasPart(DocIterator const & it) const
 {
        // it can't be a part if it is larger
@@ -555,6 +577,12 @@ void DocIterator::sanitize()
                        fixIfBroken();
                        break;
                }
+               if ((inset->inMathed() && !inset->isActive())
+                   || (!inset->inMathed() && !inset->editable())) {
+                       LYXERR0("Inset found on cursor stack is not active.");
+                       fixIfBroken();
+                       break;
+               }
                push_back(sl[i]);
                top().inset_ = inset;
                if (fixIfBroken())