From 7f177d8d4a88d84142bdd2939d4c65abe4b50a11 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Tue, 29 Jan 2019 11:20:22 +0100 Subject: [PATCH] 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 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Text2.cpp b/src/Text2.cpp index e73d1cc532..ce5259805e 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) { -- 2.39.5