BOOST_ASSERT(!empty());
if (pos() == lastpos())
return 0;
+ if (pos() > lastpos()) {
+ lyxerr << "Should not happen, but it does. " << endl;
+ return 0;
+ }
if (inMathed())
return nextAtom().nucleus();
return paragraph().isInset(pos()) ? paragraph().getInset(pos()) : 0;
}
-DocIterator::par_type DocIterator::lastpar() const
+DocIterator::pit_type DocIterator::lastpit() const
{
return inMathed() ? 0 : text()->paragraphs().size() - 1;
}
//lyxerr << "... no next pos" << endl;
// otherwise move on one paragraph if possible
- if (top.par() < lastpar()) {
+ if (top.pit() < lastpit()) {
//lyxerr << "... next par" << endl;
- ++top.par();
+ ++top.pit();
top.pos() = 0;
return;
}
if (top.idx() < lastidx()) {
//lyxerr << "... next idx" << endl;
++top.idx();
- top.par() = 0;
+ top.pit() = 0;
top.pos() = 0;
return;
}
if (empty()) {
push_back(CursorSlice(*inset_));
back().idx() = lastidx();
- back().par() = lastpar();
+ back().pit() = lastpit();
back().pos() = lastpos();
return;
}
if (top.pos() != 0) {
--top.pos();
- } else if (top.par() != 0) {
- --top.par();
+ } else if (top.pit() != 0) {
+ --top.pit();
top.pos() = lastpos();
return;
} else if (top.idx() != 0) {
--top.idx();
- top.par() = lastpar();
+ top.pit() = lastpit();
top.pos() = lastpos();
return;
} else {
if (n && n->isActive()) {
push_back(CursorSlice(*n));
back().idx() = lastidx();
- back().par() = lastpar();
+ back().pit() = lastpit();
back().pos() = lastpos();
}
}
}
-DocIterator
-StableDocIterator::asDocIterator(InsetBase * inset) const
+DocIterator StableDocIterator::asDocIterator(InsetBase * inset) const
{
// this function re-creates the cache of inset pointers
//lyxerr << "converting:\n" << *this << endl;
DocIterator dit = DocIterator(*inset);
for (size_t i = 0, n = data_.size(); i != n; ++i) {
+ if (inset == 0) {
+ // FIXME
+ lyxerr << "Should not happen, but does e.g. after C-n C-l C-z S-C-z"
+ << endl << "dit: " << dit << endl
+ << " lastpos: " << dit.lastpos() << endl;
+ //break;
+ BOOST_ASSERT(false);
+ }
dit.push_back(data_[i]);
dit.back().inset_ = inset;
if (i + 1 != n)