[LyX/master] Fix update of cursor in tab-delete when there is a selection

Jean-Marc Lasgouttes lasgouttes at lyx.org
Fri Aug 30 14:59:29 UTC 2024


commit 16be88ca18719a98a555ced268431ca1040658b7
Author: Jean-Marc Lasgouttes <lasgouttes at lyx.org>
Date:   Fri Aug 30 16:56:16 2024 +0200

    Fix update of cursor in tab-delete when there is a selection
    
    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 | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/Text.cpp b/src/Text.cpp
index 7c0b18cbfd..327e3949ee 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -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);
 					}


More information about the lyx-cvs mailing list