]> git.lyx.org Git - lyx.git/commitdiff
Fix update of cursor in tab-delete when there is a selection
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 30 Aug 2024 14:56:16 +0000 (16:56 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 30 Aug 2024 14:56:16 +0000 (16:56 +0200)
The position of the cursor should not be decreased if it is already at
the start of the paragraph. This can lead to a crash when trying to
display the caret.

src/Text.cpp

index 7c0b18cbfd05fddcdc7a203be19c913d6951bc42..327e3949ee259c4aa41b8a520b3be2e30b73034e 100644 (file)
@@ -4629,10 +4629,9 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                                        int const n = (c == ' ' ? 4 : 1);
                                        for (int i = 0; i < n
                                                  && !par.empty() && par.getChar(0) == c; ++i) {
-                                               if (cur.pit() == pit)
+                                               if (cur.pit() == pit && cur.pos() > 0)
                                                        cur.posBackward();
-                                               if (cur.realAnchor().pit() == pit
-                                                         && cur.realAnchor().pos() > 0 )
+                                               if (cur.realAnchor().pit() == pit && cur.realAnchor().pos() > 0)
                                                        cur.realAnchor().backwardPos();
                                                par.eraseChar(0, tc);
                                        }