]> git.lyx.org Git - features.git/commitdiff
Fixup 0fed10e4: make sure redraw happens as needed
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 31 Jan 2023 23:02:35 +0000 (00:02 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 31 Jan 2023 23:09:49 +0000 (00:09 +0100)
This commit had had an additional not documented change: redraws
happen only when they are needed. This did not help fix the bug, but
looked smart on first sight. Alas, I find that these smart changes
added because "why not?" tend to come back to haunt me eventually.

In particular this case, the problem was that the code tested whether
the offset of anchor paragraph had changed, but not whether the
paragraph itself had changed. This means that, when switching from one
section to another with the outliner, the view was not updated.

src/BufferView.cpp

index fd4ad50c1c8ce51094ecd4f276effad6e49620dd..ae0c71461a2876caad4b5f6278c5f34eb51b5de3 100644 (file)
@@ -1064,6 +1064,7 @@ bool BufferView::scrollToCursor(DocIterator const & dit, ScrollType how)
 
        tm.redoParagraph(bot_pit);
        int const offset = coordOffset(dit).y_;
+       pit_type const old_pit = d->anchor_pit_;
        d->anchor_pit_ = bot_pit;
 
        CursorSlice const & cs = dit.innerTextSlice();
@@ -1076,7 +1077,7 @@ bool BufferView::scrollToCursor(DocIterator const & dit, ScrollType how)
        d->anchor_ypos_ = - offset + row_dim.ascent();
        if (how == SCROLL_CENTER)
                d->anchor_ypos_ += height_/2 - row_dim.height() / 2;
-       return d->anchor_ypos_ != old_ypos;
+       return d->anchor_ypos_ != old_ypos || d->anchor_pit_ != old_pit;
 }