]> git.lyx.org Git - lyx.git/commitdiff
Some fixes.
authorAbdelrazak Younes <younes@lyx.org>
Sat, 22 Dec 2007 09:04:53 +0000 (09:04 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Sat, 22 Dec 2007 09:04:53 +0000 (09:04 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22251 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.cpp

index e6b288234662dbe1f4797b369a2907b6e103c3bd..d6dcbaa67baa82d76219f707fc754a49e4750448 100644 (file)
@@ -680,7 +680,15 @@ void BufferView::showCursor()
        CursorSlice & bot = d->cursor_.bottom();
        TextMetrics & tm = d->text_metrics_[bot.text()];
 
-       int const bot_pit = d->cursor_.bottom().pit();
+       pos_type const max_pit = pos_type(bot.text()->paragraphs().size() - 1);
+       int bot_pit = d->cursor_.bottom().pit();
+       if (bot_pit > max_pit) {
+               // FIXME: Why does this happen?
+               LYXERR0("bottom pit is greater that max pit: "
+                       << bot_pit << " > " << max_pit);
+               bot_pit = max_pit;
+       }
+
        if (bot_pit == tm.first().first - 1)
                tm.newParMetricsUp();
        else if (bot_pit == tm.last().first + 1)
@@ -708,12 +716,10 @@ void BufferView::showCursor()
 
        if (d->anchor_pit_ == 0)
                d->anchor_ypos_ = offset + pm.ascent();
-       else if (d->anchor_pit_ >= pos_type(bot.text()->paragraphs().size() - 1)) {
-               d->anchor_pit_ = bot.text()->paragraphs().size() - 1;
+       else if (d->anchor_pit_ == max_pit)
                d->anchor_ypos_ = height_ - offset - row_dim.descent();
-       } else {
+       else
                d->anchor_ypos_ = offset + pm.ascent() - height_ / 2;
-       }
 
        updateMetrics();
        buffer_.changed();
@@ -1680,7 +1686,7 @@ void BufferView::updateMetrics()
        int y2 = d->anchor_ypos_ + anchor_pm.descent();
        // We are now just below the anchor paragraph.
        pit_type pit2 = d->anchor_pit_ + 1;
-       for (; pit2 < npit && y2 < height_; ++pit2) {
+       for (; pit2 < npit && y2 <= height_; ++pit2) {
                tm.redoParagraph(pit2);
                ParagraphMetrics & pm = tm.par_metrics_[pit2];
                y2 += pm.ascent();