From fbf22bb3f39c2a91c2cee1d4bd560dce00871b28 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Tue, 2 Mar 2021 18:07:43 +0100 Subject: [PATCH] Fix random scrolling inside nested insets Happened when the BufferView was resized (e.g. math toolbars were displayed/hidden). Backported from gadmm's lyx-unstable tree https://gitlab.com/gadmm/lyx-unstable/-/commit/a868bc034cea4c Possible fix to bug #7457. --- src/BufferView.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/BufferView.cpp b/src/BufferView.cpp index 0025277e53..295b9831ac 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -954,7 +954,7 @@ bool BufferView::scrollToCursor(DocIterator const & dit, bool const recenter) LYXERR(Debug::SCROLLING, "scrolling to cursor"); CursorSlice const & bot = dit.bottom(); - TextMetrics & tm = d->text_metrics_[bot.text()]; + TextMetrics & tm = textMetrics(bot.text()); pos_type const max_pit = pos_type(bot.text()->paragraphs().size() - 1); pos_type bot_pit = bot.pit(); @@ -1021,8 +1021,10 @@ bool BufferView::scrollToCursor(DocIterator const & dit, bool const recenter) d->anchor_pit_ = bot_pit; CursorSlice const & cs = dit.innerTextSlice(); + ParagraphMetrics const & inner_pm = + textMetrics(cs.text()).parMetrics(cs.pit()); Dimension const & row_dim = - pm.getRow(cs.pos(), dit.boundary()).dim(); + inner_pm.getRow(cs.pos(), dit.boundary()).dim(); if (recenter) d->anchor_ypos_ = height_/2;