Avoid some full metrics computations related to math previews

When entering/leaving a math hull inset, a Update::Force flag was set,
in case the metrics of the inset would change because of a switch
between normal and preview representation.

When entering the inset, this code is now used only when the inset was
in preview mode.

In both cases, Update::Force is replaced with Update::SinglePar.

This requites in Text::dispatch to honor Update::SinglePar when it has
been set by some lfun, even when singleparupdate is false.

Part of bug #12297.
This commit is contained in:
Jean-Marc Lasgouttes 2023-11-27 15:13:56 +01:00
parent f7218cec18
commit 5e8578837f
2 changed files with 9 additions and 6 deletions

View File

@ -6386,7 +6386,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
// FIXME: the following code should go in favor of fine grained
// update flag treatment.
if (singleParUpdate) {
if (singleParUpdate || cur.result().screenUpdate() & Update::SinglePar) {
// Inserting characters does not change par height in general. So, try
// to update _only_ this paragraph. BufferView will detect if a full
// metrics update is needed anyway.

View File

@ -902,7 +902,7 @@ bool InsetMathHull::notifyCursorLeaves(Cursor const & old, Cursor & cur)
{
if (RenderPreview::previewMath()) {
reloadPreview(old);
cur.screenUpdateFlags(Update::Force);
cur.screenUpdateFlags(Update::SinglePar);
}
return false;
}
@ -2273,14 +2273,17 @@ void InsetMathHull::handleFont2(Cursor & cur, docstring const & arg)
void InsetMathHull::edit(Cursor & cur, bool front, EntryDirection entry_from)
{
bool const has_preview = previewState(&cur.bv());
cur.push(*this);
bool enter_front = (entry_from == Inset::ENTRY_DIRECTION_LEFT ||
(entry_from == Inset::ENTRY_DIRECTION_IGNORE && front));
enter_front ? idxFirst(cur) : idxLast(cur);
// The inset formula dimension is not necessarily the same as the
// one of the instant preview image, so we have to indicate to the
// BufferView that a metrics update is needed.
cur.screenUpdateFlags(Update::Force);
if (has_preview) {
// The inset formula dimension is in general different from the
// one of the instant preview image, so we have to indicate to the
// BufferView that a metrics update is needed.
cur.screenUpdateFlags(Update::SinglePar);
}
}