X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FBufferView.cpp;h=e75bc5e0b93f0a82b69df51b1ceb5b27ae5e2560;hb=a8572c1358d5d2e66612e9f44329a6ffd33516a6;hp=769d1a9026b5249491609bc7743161376982ae51;hpb=907f020724b4d73a75644642f3e097f74c75c3b5;p=lyx.git diff --git a/src/BufferView.cpp b/src/BufferView.cpp index 769d1a9026..e75bc5e0b9 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -35,7 +35,6 @@ #include "Language.h" #include "LaTeXFeatures.h" #include "LayoutFile.h" -#include "Length.h" #include "Lexer.h" #include "LyX.h" #include "LyXAction.h" @@ -81,6 +80,7 @@ #include "support/filetools.h" #include "support/gettext.h" #include "support/lassert.h" +#include "support/Length.h" #include "support/lstrings.h" #include "support/lyxlib.h" #include "support/Package.h" @@ -947,7 +947,7 @@ bool BufferView::scrollToCursor(DocIterator const & dit, bool const recenter) TextMetrics & tm = d->text_metrics_[bot.text()]; pos_type const max_pit = pos_type(bot.text()->paragraphs().size() - 1); - int bot_pit = bot.pit(); + pos_type bot_pit = bot.pit(); if (bot_pit > max_pit) { // FIXME: Why does this happen? LYXERR0("bottom pit is greater that max pit: " @@ -2777,7 +2777,7 @@ bool BufferView::singleParUpdate() Text & buftext = buffer_.text(); pit_type const bottom_pit = d->cursor_.bottom().pit(); TextMetrics & tm = textMetrics(&buftext); - int old_height = tm.parMetrics(bottom_pit).height(); + Dimension const old_dim = tm.parMetrics(bottom_pit).dim(); // make sure inline completion pointer is ok if (d->inlineCompletionPos_.fixIfBroken()) @@ -2788,11 +2788,16 @@ bool BufferView::singleParUpdate() // (if this paragraph contains insets etc., rebreaking will // recursively descend) tm.redoParagraph(bottom_pit); - ParagraphMetrics const & pm = tm.parMetrics(bottom_pit); - if (pm.height() != old_height) + ParagraphMetrics & pm = tm.parMetrics(bottom_pit); + if (pm.height() != old_dim.height()) { // Paragraph height has changed so we cannot proceed to // the singlePar optimisation. return false; + } + // Since position() points to the baseline of the first row, we + // may have to update it. See ticket #11601 for an example where + // the height does not change but the ascent does. + pm.setPosition(pm.position() - old_dim.ascent() + pm.ascent()); tm.updatePosCache(bottom_pit); @@ -2840,7 +2845,7 @@ void BufferView::updateMetrics(Update::flags & update_flags) // Rebreak anchor paragraph. tm.redoParagraph(d->anchor_pit_); - ParagraphMetrics & anchor_pm = tm.par_metrics_[d->anchor_pit_]; + ParagraphMetrics & anchor_pm = tm.parMetrics(d->anchor_pit_); // position anchor if (d->anchor_pit_ == 0) { @@ -2867,7 +2872,7 @@ void BufferView::updateMetrics(Update::flags & update_flags) pit_type pit1 = d->anchor_pit_ - 1; for (; pit1 >= 0 && y1 >= 0; --pit1) { tm.redoParagraph(pit1); - ParagraphMetrics & pm = tm.par_metrics_[pit1]; + ParagraphMetrics & pm = tm.parMetrics(pit1); y1 -= pm.descent(); // Save the paragraph position in the cache. pm.setPosition(y1); @@ -2881,7 +2886,7 @@ void BufferView::updateMetrics(Update::flags & update_flags) pit_type pit2 = d->anchor_pit_ + 1; for (; pit2 < npit && y2 <= height_; ++pit2) { tm.redoParagraph(pit2); - ParagraphMetrics & pm = tm.par_metrics_[pit2]; + ParagraphMetrics & pm = tm.parMetrics(pit2); y2 += pm.ascent(); // Save the paragraph position in the cache. pm.setPosition(y2); @@ -3272,6 +3277,7 @@ void BufferView::draw(frontend::Painter & pain, bool paint_caret) : "\t\t *** END DRAWING ***")); // The scrollbar needs an update. + // FIXME: does it always? see ticket #11947. updateScrollbar(); // Normalize anchor for next time