]> git.lyx.org Git - lyx.git/commitdiff
Do not try to put cursor after space if no space was kept
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 13 Apr 2020 10:58:43 +0000 (12:58 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 17 Apr 2020 08:40:54 +0000 (10:40 +0200)
The logic was wrong and could cause crashes

Fixes bug #11777.

src/Text2.cpp
status.23x

index ce5259805ebba23140c7da4bc902bb0856a35800..71569dba46c968cc167a084650b4acf272098b71 100644 (file)
@@ -797,8 +797,9 @@ void fixCursorAfterDelete(CursorSlice & cur, CursorSlice const & where,
                return;
 
        // If cursor position is after the deletion place update it
+       // but if we are not at start of line keep it after the space that was kept.
        if (cur.pos() > from)
-               cur.pos() = max(from + 1, cur.pos() - num_chars);
+               cur.pos() = max(from + (from > 0), cur.pos() - num_chars);
 
        // Check also if we don't want to set the cursor on a spot behind the
        // pagragraph because we erased the last character.
index acd7e1233b794b9264daadd9b0c652abdbff6ba6..d184ac55d00afba499b1d9faac4d4b2585eaa24c 100644 (file)
@@ -105,6 +105,8 @@ What's new
 - Avoid crash in some cases where a dialog is shown during operation
   (bug 11763).
 
+- Fix crash with nested insets when spaces are removed automatically (bug 11777).
+
 * INTERNALS