]> git.lyx.org Git - lyx.git/blobdiff - src/DocIterator.cpp
inputenc only expects one option
[lyx.git] / src / DocIterator.cpp
index bdad90f4fc225d9f147044c95c5b13fb8f0f82ed..94b7792b9afa849d9b9cf8868d21414f4808f934 100644 (file)
@@ -44,23 +44,6 @@ using namespace lyx::support;
 namespace lyx {
 
 
-DocIterator::DocIterator()
-       : boundary_(false), inset_(nullptr), buffer_(nullptr)
-{}
-
-
-// We could be able to get rid of this if only every BufferView were
-// associated to a buffer on construction.
-DocIterator::DocIterator(Buffer * buf)
-       : boundary_(false), inset_(nullptr), buffer_(buf)
-{}
-
-
-DocIterator::DocIterator(Buffer * buf, Inset * inset)
-       : boundary_(false), inset_(inset), buffer_(buf)
-{}
-
-
 DocIterator doc_iterator_begin(const Buffer * buf0, const Inset * inset0)
 {
        Buffer * buf = const_cast<Buffer *>(buf0);
@@ -271,7 +254,7 @@ pos_type DocIterator::lastpos() const
 }
 
 
-DocIterator::idx_type DocIterator::lastidx() const
+idx_type DocIterator::lastidx() const
 {
        return top().lastidx();
 }
@@ -298,13 +281,13 @@ size_t DocIterator::nrows() const
 }
 
 
-DocIterator::row_type DocIterator::row() const
+row_type DocIterator::row() const
 {
        return top().row();
 }
 
 
-DocIterator::col_type DocIterator::col() const
+col_type DocIterator::col() const
 {
        return top().col();
 }
@@ -500,6 +483,18 @@ void DocIterator::backwardPos()
 }
 
 
+void DocIterator::backwardPosIgnoreCollapsed()
+{
+       backwardPos();
+       if (inTexted()) {
+               Inset const * ins = realInset();
+               if (ins && !ins->editable()) {
+                       pop_back(); // move out of collapsed inset
+               }
+       }
+}
+
+
 #if 0
 // works, but currently not needed
 void DocIterator::backwardInset()
@@ -554,6 +549,11 @@ void DocIterator::updateInsets(Inset * inset)
        size_t const n = slices_.size();
        slices_.resize(0);
        for (size_t i = 0 ; i < n; ++i) {
+               if (dit[i].empty() && prevMath().lyxCode() == MATH_SCRIPT_CODE)
+                       // Workaround: With empty optional argument and a trailing script,
+                       // we have empty slices in math macro args (#11676)
+                       // FIXME: Find real cause!
+                       continue;
                LBUFERR(inset);
                push_back(dit[i]);
                top().inset_ = inset;
@@ -633,11 +633,7 @@ void DocIterator::sanitize()
        for (size_t i = 0, n = sl.size(); i != n; ++i) {
                if (inset == nullptr) {
                        // FIXME
-                       LYXERR0(" Should not happen, but does e.g. after "
-                               "C-n C-l C-z S-C-z\n"
-                               << " or when a Buffer has been concurrently edited by two views"
-                               << '\n' << "dit: " << *this << '\n'
-                               << " lastpos: " << slices_[i].lastpos());
+                       LYXERR0("Null inset on cursor stack.");
                        fixIfBroken();
                        break;
                }
@@ -715,7 +711,7 @@ void DocIterator::append(vector<CursorSlice> const & x)
 }
 
 
-void DocIterator::append(DocIterator::idx_type idx, pos_type pos)
+void DocIterator::append(idx_type idx, pos_type pos)
 {
        slices_.push_back(CursorSlice());
        top().idx() = idx;