diff --git a/src/Cursor.cpp b/src/Cursor.cpp index ce0281251a..7afefcf372 100644 --- a/src/Cursor.cpp +++ b/src/Cursor.cpp @@ -2217,7 +2217,7 @@ bool Cursor::upDownInText(bool up, bool & updateNeeded) if (updateNeeded) forceBufferUpdate(); } - return valid_destination; + return false; } // with and without selection are handled differently diff --git a/src/Cursor.h b/src/Cursor.h index 4ef5bc9d6c..f549047985 100644 --- a/src/Cursor.h +++ b/src/Cursor.h @@ -496,9 +496,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 the cursor has moved or can move, updateNeeded - /// set to true if fullscreen update is needed, otherwise it's not - /// touched + /// return true if successful, updateNeeded set to true if fullscreen + /// update is needed, otherwise it's not touched bool upDownInText(bool up, bool & updateNeeded); /// move up/down in math or any non text inset, call for LFUN_UP/DOWN /// return true if successful diff --git a/src/FuncCode.h b/src/FuncCode.h index 8337c1f921..8a0fe35d4a 100644 --- a/src/FuncCode.h +++ b/src/FuncCode.h @@ -500,8 +500,6 @@ enum FuncCode LFUN_SPELLING_ADD_LOCAL, // jspitzm 20210306 // 390 LFUN_SPELLING_REMOVE_LOCAL, // jspitzm 20210307 - LFUN_FINISHED_DOWN, // lasgouttes 20210629 - LFUN_FINISHED_UP, // lasgouttes 20210629 LFUN_BRANCH_SYNC_ALL, // sanda 20220415 LFUN_LASTACTION // end of the table }; diff --git a/src/LyXAction.cpp b/src/LyXAction.cpp index 96b492e45a..8480334955 100644 --- a/src/LyXAction.cpp +++ b/src/LyXAction.cpp @@ -1677,22 +1677,6 @@ void LyXAction::init() */ { LFUN_FINISHED_RIGHT, "", ReadOnly, Hidden }, -/*! - * \var lyx::FuncCode lyx::LFUN_FINISHED_UP - * \li Action: Moves the cursor out of the current slice, going up. - * \li Notion: See also #LFUN_FINISHED_DOWN. - * \endvar - */ - { LFUN_FINISHED_UP, "", ReadOnly, Hidden }, - -/*! - * \var lyx::FuncCode lyx::LFUN_FINISHED_DOWN - * \li Action: Moves the cursor out of the current slice, going down. - * \li Notion: See also #LFUN_FINISHED_DOWN. - * \endvar - */ - { LFUN_FINISHED_DOWN, "", ReadOnly, Hidden }, - /*! * \var lyx::FuncCode lyx::LFUN_FLEX_INSERT * \li Action: Inserts CharStyle, Custom inset or XML short element. diff --git a/src/Text3.cpp b/src/Text3.cpp index da23857c1a..1c9a3505c1 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -914,12 +914,14 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) case LFUN_UP: case LFUN_DOWN: { // stop/start the selection - bool const select = cmd.action() == LFUN_DOWN_SELECT - || cmd.action() == LFUN_UP_SELECT; - // move cursor up/down - bool const up = cmd.action() == LFUN_UP_SELECT || cmd.action() == LFUN_UP; + bool select = cmd.action() == LFUN_DOWN_SELECT || + cmd.action() == LFUN_UP_SELECT; - if (!cur.atFirstOrLastRow(up)) { + // move cursor up/down + bool up = cmd.action() == LFUN_UP_SELECT || cmd.action() == LFUN_UP; + bool const atFirstOrLastRow = cur.atFirstOrLastRow(up); + + if (!atFirstOrLastRow) { needsUpdate |= cur.selHandle(select); cur.upDownInText(up, needsUpdate); needsUpdate |= cur.beforeDispatchCursor().inMathed(); @@ -935,35 +937,13 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd) cur.forceBufferUpdate(); break; } - needsUpdate |= cur.selHandle(select); - bool const can_move = cur.upDownInText(up, needsUpdate); - // if the cursor can be moved up or down at an upper level, - // delegate the dispatch to next level. Otherwise, we are - // done. - if (can_move) { - cmd = FuncRequest(up ? LFUN_FINISHED_UP : LFUN_FINISHED_DOWN); - cur.undispatched(); - } - } - break; - } - - case LFUN_FINISHED_UP: - case LFUN_FINISHED_DOWN: { - // move cursor up/down - bool const up = cmd.action() == LFUN_FINISHED_UP; - - if (!cur.atFirstOrLastRow(up)) { + // if the cursor cannot be moved up or down do not remove + // the selection right now, but wait for the next dispatch. + if (select) + needsUpdate |= cur.selHandle(select); cur.upDownInText(up, needsUpdate); - needsUpdate |= cur.beforeDispatchCursor().inMathed(); - } else { - bool const can_move = cur.upDownInText(up, needsUpdate); - // if the cursor can be moved up or down and we are not - // moving cusor at top level, wait for the next dispatch. - // Otherwise, we are done. - if (can_move) - cur.undispatched(); + cur.undispatched(); } break;