Fix up 5577e877: remove logic error

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).
This commit is contained in:
Jean-Marc Lasgouttes 2024-05-03 14:28:30 +02:00
parent f58957747a
commit 9f33db8f53
3 changed files with 23 additions and 17 deletions

View 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();
}
return false;
updateTextTargetOffset();
}
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;
}

View 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);

View 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();
}