[LyX/master] Fix random scrolling inside nested insets

Jean-Marc Lasgouttes lasgouttes at lyx.org
Tue Mar 2 17:05:30 UTC 2021


commit fbf22bb3f39c2a91c2cee1d4bd560dce00871b28
Author: Jean-Marc Lasgouttes <lasgouttes at lyx.org>
Date:   Tue Mar 2 18:07:43 2021 +0100

    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 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 0025277..295b983 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;


More information about the lyx-cvs mailing list