]> git.lyx.org Git - features.git/commitdiff
Fix assertion from setCursor() in outline-down/up
authorScott Kostyshak <skostysh@lyx.org>
Thu, 26 Mar 2020 22:57:25 +0000 (18:57 -0400)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 18 Jun 2020 13:48:55 +0000 (15:48 +0200)
The function outline() itself can change the cursor position in some
cases so we need to store the old position before calling outline().

Spotted by Kornel. For an example file that triggered the assertion,
see:

  https://www.mail-archive.com/search?l=mid&q=20200326183314.09ad4c7c%40admin1-desktop

This commit amends adb7283b.

src/Text3.cpp

index 2f6afd5be542e81637859f9c4d9fdd1a695bb29a..f290ca690c8f62ead95e1aa9550ad42e8ba634c7 100644 (file)
@@ -2759,19 +2759,23 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                }
                break;
 
-       case LFUN_OUTLINE_UP:
+       case LFUN_OUTLINE_UP: {
+               pos_type const opos = cur.pos();
                outline(OutlineUp, cur, this);
-               setCursor(cur, cur.pit(), cur.pos());
+               setCursor(cur, cur.pit(), opos);
                cur.forceBufferUpdate();
                needsUpdate = true;
                break;
+       }
 
-       case LFUN_OUTLINE_DOWN:
+       case LFUN_OUTLINE_DOWN: {
+               pos_type const opos = cur.pos();
                outline(OutlineDown, cur, this);
-               setCursor(cur, cur.pit(), cur.pos());
+               setCursor(cur, cur.pit(), opos);
                cur.forceBufferUpdate();
                needsUpdate = true;
                break;
+       }
 
        case LFUN_OUTLINE_IN:
                outline(OutlineIn, cur, this);