]> git.lyx.org Git - lyx.git/commitdiff
Make DEPM respect current cursor position.
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 21 Dec 2018 14:36:55 +0000 (15:36 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 21 Dec 2018 21:18:40 +0000 (22:18 +0100)
Spaces are now conserved when they surround current cursor. Examples:
  abc   |   def
becomes
  abc | def
after DEPM and
  abc |
is kept as it is.

Fixes ticket #11412.

(cherry picked from commit dff0c5729e6eec4c799f60171e4d0a377327ab10)

src/Text2.cpp
status.23x

index e0f5963f8b097f2acae567a675091391173b180b..d6f5a83ef0f8ddcb56c09d48c8069c2beeb6eb10 100644 (file)
@@ -850,7 +850,7 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
                && old.pos() == cur[depth].pos();
 
        // If the chars around the old cursor were spaces, delete some of
-       // them , but only if the cursor has really moved.
+       // them, but only if the cursor has really moved.
        if (!same_par_pos) {
                // find range of spaces around cursors
                int from = old.pos();
@@ -868,6 +868,9 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
                if (from != to && from > 0 && to < oldpar.size())
                        ++from;
 
+               if (same_par && cur.pos() > from && cur.pos() < to)
+                       ++from;
+
                // Remove spaces and adapt cursor.
                if (from < to) {
                        oldpar.eraseChars(from, to, cur.buffer()->params().track_changes);
@@ -884,7 +887,7 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
                }
        }
 
-       // only do our magic if we changed paragraph
+       // only do our other magic if we changed paragraph
        if (same_par)
                return false;
 
index 9680d6f1f345d4c4583284f54f37d5ae4d26121f..386df1ad943827a1bf65ae2305dce76de2128c7d 100644 (file)
@@ -39,6 +39,8 @@ What's new
 
 - Insert new graphics inset on the correct cursor position.
 
+- Fix regression where spaces are disappearing when editing text (bug 11412).
+
 
 * DOCUMENTATION AND LOCALIZATION