commit 7f177d8d4a88d84142bdd2939d4c65abe4b50a11
Author: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date:   Tue Jan 29 11:20:22 2019 +0100

    Improve DEPM when change tracking is on
    
    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 |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/Text2.cpp b/src/Text2.cpp
index e73d1cc..ce52598 100644
--- a/src/Text2.cpp
+++ b/src/Text2.cpp
@@ -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) {

Reply via email to