]> git.lyx.org Git - features.git/commitdiff
Revert "Always remove selection after cursor up/down"
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 25 Oct 2022 16:18:49 +0000 (18:18 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 27 Oct 2022 13:07:57 +0000 (15:07 +0200)
This reverts commit 008a0825e8d67b9c0a3d31b906f04cd7b8fd18a8.

This commit was part of bug #12310. The goal was to remove the
selection when using "up" at the start of selection (so that the
cursor cannot move). Unfortunately, it creates navigation issues for
insets inside tabulars.

Since the fix was minor, the safest decision is to revert.

The part of ticket #12310 that resets selection with
char-forwars/backward when moving is not possible still works.

Fixes bug #12593.

src/Cursor.cpp
src/Cursor.h
src/FuncCode.h
src/LyXAction.cpp
src/Text3.cpp

index ce0281251a75850c154665de7610ae020aabc05d..7afefcf372e3b7cd26558c69af60f8dd28ecf55d 100644 (file)
@@ -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
index 4ef5bc9d6cbde7b7500398c4f092a134766417f0..f5490479851b8322f7b095d0bf4ae6ce0c3d152b 100644 (file)
@@ -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
index 8337c1f9210e277b3ca2ac578a8a4bda7caf863b..8a0fe35d4a736edf8f7f2f52aeb89b5cc32bbafd 100644 (file)
@@ -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
 };
index 96b492e45a2e148dd7c4e4d70d578116fdb3a744..848033495576856145451d324718e558967c9a36 100644 (file)
@@ -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.
index da23857c1ab6c4266099449cc1da0cfd7394ddb2..1c9a3505c14646d856f5f06d47dedac80a26e7ee 100644 (file)
@@ -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;
+               bool 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 up = cmd.action() == LFUN_UP_SELECT || cmd.action() == LFUN_UP;
+               bool const atFirstOrLastRow = cur.atFirstOrLastRow(up);
 
-               if (!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;