Paragraph::value_type Paragraph::Pimpl::getChar(pos_type pos) const
{
+ lyx::Assert(pos <= size());
+
// This is stronger, and I belive that this is the assertion
// that we should really use. (Lgb)
+ // Rationale - getChar() is really text[]. getInset(getChar(size()))
+ // makes no sense (crashes). The fact we return '\0' should be
+ // evidence enough - jbl
//lyx::Assert(pos < size());
-#warning I believe pos() == size() is valid if the cursor is at the last position of the par. (Andre)
- lyx::Assert(pos <= size());
-
-#if 0
+#if 1
// This is in the critical path for loading!
pos_type const siz = size();
- // Then this has no meaning. (Lgb)
- if (!siz || pos == siz) {
+ if (pos == siz) {
lyxerr << "getChar() on pos " << pos << " in par id "
<< owner_->id() << " of size " << siz
<< " is a bit silly !" << endl;
int labeladdon = 0;
int maxwidth = 0;
- // Check if any insets are larger
- for (pos_type pos = row->pos(); pos < pos_end; ++pos) {
- if (row->par()->isInset(pos)) {
- tmpfont = getFont(bview->buffer(), row->par(), pos);
- tmpinset = row->par()->getInset(pos);
- if (tmpinset) {
+ if (!row->par()->empty()) {
+ // Check if any insets are larger
+ for (pos_type pos = row->pos(); pos <= pos_end; ++pos) {
+ if (row->par()->isInset(pos)) {
+ tmpfont = getFont(bview->buffer(), row->par(), pos);
+ tmpinset = row->par()->getInset(pos);
+ if (tmpinset) {
#if 1 // this is needed for deep update on initialitation
- tmpinset->update(bview, tmpfont);
+ tmpinset->update(bview, tmpfont);
#endif
- asc = tmpinset->ascent(bview, tmpfont);
- desc = tmpinset->descent(bview, tmpfont);
- maxwidth += tmpinset->width(bview, tmpfont);
- maxasc = max(maxasc, asc);
- maxdesc = max(maxdesc, desc);
+ asc = tmpinset->ascent(bview, tmpfont);
+ desc = tmpinset->descent(bview, tmpfont);
+ maxwidth += tmpinset->width(bview, tmpfont);
+ maxasc = max(maxasc, asc);
+ maxdesc = max(maxdesc, desc);
+ }
+ } else {
+ maxwidth += singleWidth(bview, row->par(), pos);
}
- } else {
- maxwidth += singleWidth(bview, row->par(), pos);
}
}