]> git.lyx.org Git - lyx.git/commitdiff
Fix paragraph position in TextMetrics::singleParUpdate()
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 13 Jul 2020 21:29:15 +0000 (23:29 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 14 Jul 2020 17:48:55 +0000 (19:48 +0200)
When running redoParagraph, it may happen that the ascent of the first
row changes. Since the ParagraphMetrics position is actually the
baseline of its first row, it may be necessary to update it.

Fixes bug #11601.

(cherry picked from commit 2e8c9cfc832d876ff66e47ae7aadc30fe9328e9d)

src/BufferView.cpp
src/update_flags.h
status.23x

index c15b7d3b88d3c2ea29e7ad9a5b1156d27570a98f..e7e69f63e0a5eb4543ddb8f2ef4e96f86b459241 100644 (file)
@@ -2754,7 +2754,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())
@@ -2765,11 +2765,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.par_metrics_[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);
 
index a40e88c5567a1d200612478cdd835214208937b1..af71c0e78d5f8452fbfb8647fcd853036e68fd92 100644 (file)
@@ -26,7 +26,6 @@ namespace Update {
                /// Force a full redraw (but no metrics computations)
                ForceDraw = 4,
                /// Try to rebreak only the current paragraph metrics.
-               /// (currently ignored!)
                SinglePar = 8,
                /// Only the inset decorations need to be redrawn, no text metrics
                /// update is needed.
index 46c3f64fb7aece4f7cc1e46daaba80d7eca30602..944a0391a24e355e009a40b11decd1318ddd74a8 100644 (file)
@@ -74,6 +74,8 @@ What's new
 
 - Fix the LyX icon in the Wayland dash (bug 11847).
 
+- Fix display bug when typing in a paragraph where row heights change (bug 11601).
+
 
 * INTERNALS