]> git.lyx.org Git - lyx.git/commitdiff
Fix up 5577e877: remove logic error
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 3 May 2024 12:28:30 +0000 (14:28 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 3 May 2024 12:38:32 +0000 (14:38 +0200)
Commit 5577e877 introduces forceUpdateBuffer() to delay actual
updatBuffer() calls to a central place.

In Cursor::upDownInText, the updateNeeded flag (which triggers
Update::Force update flag) is set to true when Cursor::checkDepm
returns true. This is fine, except that checkDepm also leads to a
forceBufferUpdate() call.

The logic in the method was such that, when updateNeeded is already
true when entering, forceBufferUpdate() will be called even though
checkDepm did not request it.

Fixes a slight delay with selecting in MergedManual (the manual of
manuals).

src/Cursor.cpp
src/Cursor.h
src/Text.cpp

index 45ae34c4b265c3fc14d093ba0fca680e1e7ad5e8..c1427f731afd642da8502008541f427ba5ceb2d1 100644 (file)
@@ -2143,7 +2143,7 @@ bool Cursor::mathBackward(bool word)
 }
 
 
-bool Cursor::upDownInText(bool up, bool & updateNeeded)
+bool Cursor::upDownInText(bool up)
 {
        LASSERT(text(), return false);
 
@@ -2153,6 +2153,9 @@ bool Cursor::upDownInText(bool up, bool & updateNeeded)
        getPos(xo, yo);
        xo = beforeDispatchPosX_;
 
+       // Is a full repaint necessary?
+       bool updateNeeded = false;
+
        // update the targetX - this is here before the "return false"
        // to set a new target which can be used by InsetTexts above
        // if we cannot move up/down inside this inset anymore
@@ -2221,12 +2224,13 @@ bool Cursor::upDownInText(bool up, bool & updateNeeded)
                        dummy.pos() = dummy.pos() == 0 ? dummy.lastpos() : 0;
                        dummy.pit() = dummy.pit() == 0 ? dummy.lastpit() : 0;
 
-                       updateNeeded |= bv().checkDepm(dummy, *this);
-                       updateTextTargetOffset();
-                       if (updateNeeded)
+                       if (bv().checkDepm(dummy, *this)) {
+                               updateNeeded = true;
                                forceBufferUpdate();
+                       }
+                       updateTextTargetOffset();
                }
-               return false;
+               return updateNeeded;
        }
 
        // with and without selection are handled differently
@@ -2252,6 +2256,7 @@ bool Cursor::upDownInText(bool up, bool & updateNeeded)
                        ++dummy.pos();
                if (bv().checkDepm(dummy, old)) {
                        updateNeeded = true;
+                       forceBufferUpdate();
                        // Make sure that cur gets back whatever happened to dummy (Lgb)
                        operator=(dummy);
                }
@@ -2292,13 +2297,14 @@ bool Cursor::upDownInText(bool up, bool & updateNeeded)
                // When selection==false, this is done by TextMetrics::editXY
                setCurrentFont();
 
-               updateNeeded |= bv().checkDepm(*this, old);
+               if (bv().checkDepm(*this, old)) {
+                       updateNeeded = true;
+                       forceBufferUpdate();
+               }
        }
 
-       if (updateNeeded)
-               forceBufferUpdate();
        updateTextTargetOffset();
-       return true;
+       return updateNeeded;
 }
 
 
index e362073ef44d7168bb6205d653248beeaa339c69..094a540f24e1dbb6c18609817b7db9a36b9c147f 100644 (file)
@@ -506,9 +506,8 @@ public:
        /// return true if fullscreen update is needed
        bool down();
        /// move up/down in a text inset, called for LFUN_UP/DOWN,
-       /// return true if successful, updateNeeded set to true if fullscreen
-       /// update is needed, otherwise it's not touched
-       bool upDownInText(bool up, bool & updateNeeded);
+       /// return true if fullscreen update is needed
+       bool upDownInText(bool up);
        /// move up/down in math or any non text inset, call for LFUN_UP/DOWN
        /// return true if successful
        bool upDownInMath(bool up);
index 55e150d6ac263fa9c46f4714f73b56a0acbcf893..44ca43f3aedbb901d408aec9b078b2fef6551589 100644 (file)
@@ -4333,7 +4333,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
 
                if (!atFirstOrLastRow) {
                        needsUpdate |= cur.selHandle(select);
-                       cur.upDownInText(up, needsUpdate);
+                       needsUpdate |= cur.upDownInText(up);
                        needsUpdate |= cur.beforeDispatchCursor().inMathed();
                } else {
                        pos_type newpos = up ? 0 : cur.lastpos();
@@ -4341,10 +4341,11 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                                needsUpdate |= cur.selHandle(select);
                                // we do not reset the targetx of the cursor
                                cur.pos() = newpos;
-                               needsUpdate |= bv->checkDepm(cur, bv->cursor());
-                               cur.updateTextTargetOffset();
-                               if (needsUpdate)
+                               if (bv->checkDepm(cur, bv->cursor())) {
+                                       needsUpdate = true;
                                        cur.forceBufferUpdate();
+                               }
+                               cur.updateTextTargetOffset();
                                break;
                        }
 
@@ -4352,7 +4353,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                        // the selection right now, but wait for the next dispatch.
                        if (select)
                                needsUpdate |= cur.selHandle(select);
-                       cur.upDownInText(up, needsUpdate);
+                       needsUpdate |= cur.upDownInText(up);
                        cur.undispatched();
                }