Fix paragraph position in TextMetrics::singleParUpdate()

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 2e8c9cfc83)
This commit is contained in:
Jean-Marc Lasgouttes 2020-07-13 23:29:15 +02:00
parent 43ccceda39
commit d968717940
3 changed files with 10 additions and 4 deletions

View File

@ -2754,7 +2754,7 @@ bool BufferView::singleParUpdate()
Text & buftext = buffer_.text(); Text & buftext = buffer_.text();
pit_type const bottom_pit = d->cursor_.bottom().pit(); pit_type const bottom_pit = d->cursor_.bottom().pit();
TextMetrics & tm = textMetrics(&buftext); 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 // make sure inline completion pointer is ok
if (d->inlineCompletionPos_.fixIfBroken()) if (d->inlineCompletionPos_.fixIfBroken())
@ -2765,11 +2765,16 @@ bool BufferView::singleParUpdate()
// (if this paragraph contains insets etc., rebreaking will // (if this paragraph contains insets etc., rebreaking will
// recursively descend) // recursively descend)
tm.redoParagraph(bottom_pit); tm.redoParagraph(bottom_pit);
ParagraphMetrics const & pm = tm.parMetrics(bottom_pit); ParagraphMetrics & pm = tm.par_metrics_[bottom_pit];
if (pm.height() != old_height) if (pm.height() != old_dim.height()) {
// Paragraph height has changed so we cannot proceed to // Paragraph height has changed so we cannot proceed to
// the singlePar optimisation. // the singlePar optimisation.
return false; 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); tm.updatePosCache(bottom_pit);

View File

@ -26,7 +26,6 @@ namespace Update {
/// Force a full redraw (but no metrics computations) /// Force a full redraw (but no metrics computations)
ForceDraw = 4, ForceDraw = 4,
/// Try to rebreak only the current paragraph metrics. /// Try to rebreak only the current paragraph metrics.
/// (currently ignored!)
SinglePar = 8, SinglePar = 8,
/// Only the inset decorations need to be redrawn, no text metrics /// Only the inset decorations need to be redrawn, no text metrics
/// update is needed. /// update is needed.

View File

@ -74,6 +74,8 @@ What's new
- Fix the LyX icon in the Wayland dash (bug 11847). - 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 * INTERNALS