]> git.lyx.org Git - features.git/commitdiff
Avoid some full metrics computations related to math previews
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 27 Nov 2023 14:13:56 +0000 (15:13 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 5 Apr 2024 11:06:26 +0000 (13:06 +0200)
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
src/mathed/InsetMathHull.cpp

index d5a1069fa1f4afcae0f155c9f071958bc4009fc6..2684309dec916075065181e347ad6c5c8bc55dd4 100644 (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.
index 94d293870d6911365b13c9395d798e864df1306a..34c319ea5c3dc183a15d8e5e23bfc3820f7f84b5 100644 (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);
+       }
 }