commit 5e8578837fea0321998eac04222102986261666d
Author: Jean-Marc Lasgouttes <[email protected]>
Date: Mon Nov 27 15:13:56 2023 +0100
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.
---
src/Text.cpp | 2 +-
src/mathed/InsetMathHull.cpp | 13 ++++++++-----
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/Text.cpp b/src/Text.cpp
index d5a1069fa1..2684309dec 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -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.
diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index 94d293870d..34c319ea5c 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -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);
+ }
}
--
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs