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.
This commit is contained in:
Jean-Marc Lasgouttes 2021-03-02 18:07:43 +01:00
parent 2eab3d2e06
commit fbf22bb3f3

View File

@ -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;