]> git.lyx.org Git - lyx.git/commitdiff
Improve DEPM when change tracking is on
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 29 Jan 2019 10:20:22 +0000 (11:20 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 15 Feb 2019 10:04:28 +0000 (11:04 +0100)
A typical problem when change tracking is on is:
1/ insert a new space between two words (as if you want to insert a new one)
2/ move the cursor
3/ see how one has one inserted and one deleted space, whereas one would expect nothing.

The problem is fixed in a general way in master, but here we propose
a simpler one, where the spaces that we keep are the ones at the end
of the sequence of spaces.

Part of #11412.

src/Text2.cpp

index e73d1cc532aa2219747ea03fb499b23b340775c6..ce5259805ebba23140c7da4bc902bb0856a35800 100644 (file)
@@ -866,11 +866,12 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
                        ++to;
 
                // If we are not at the start of the paragraph, keep one space
-               if (from != to && from > 0)
-                       ++from;
-
-               if (same_par && cur.pos() >= from && cur.pos() < to)
-                       ++from;
+               if (from != to && from > 0) {
+                       --to;
+                       // if the new cursor is inside the sequence of spaces, keep one more space
+                       if (same_par && cur.pos() > from && cur.pos() <= to)
+                               --to;
+               }
 
                // Remove spaces and adapt cursor.
                if (from < to) {