]> git.lyx.org Git - lyx.git/commitdiff
Allow to type a space in front of another one
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 14 Jan 2019 15:37:10 +0000 (16:37 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 16 Jan 2019 09:38:47 +0000 (10:38 +0100)
This is a follow-up to 714b731e. This fixes the issue when the cursor
is in front of a space
  abc| def
and one inserts another space (to start a word). DEPM would eat one
space and produce
  abc |def
instead of
  abc | def

Additionally, fix the same_par boolean, wheich did not take the cell
index into account.

Related to ticket #11412.

(cherry picked from commit 7848d3c90c0837e8e8549db37bf4bc5cd7e7dad1)

src/Text2.cpp

index d6f5a83ef0f8ddcb56c09d48c8069c2beeb6eb10..bcd38f447c2b39386cbe5d2770c16d9f432a169d 100644 (file)
@@ -824,8 +824,8 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
           There are still some small problems that can lead to
           double spaces stored in the document file or space at
           the beginning of paragraphs(). This happens if you have
-          the cursor between to spaces and then save. Or if you
-          cut and paste and the selection have a space at the
+          the cursor between two spaces and then save. Or if you
+          cut and paste and the selection has a space at the
           beginning and then save right after the paste. (Lgb)
        */
 
@@ -845,7 +845,8 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
 
        // Whether a common inset is found and whether the cursor is still in
        // the same paragraph (possibly nested).
-       bool const same_par = depth < cur.depth() && old.pit() == cur[depth].pit();
+       bool const same_par = depth < cur.depth() && old.idx() == cur[depth].idx()
+               && old.pit() == cur[depth].pit();
        bool const same_par_pos = depth == cur.depth() - 1 && same_par
                && old.pos() == cur[depth].pos();
 
@@ -868,7 +869,7 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
                if (from != to && from > 0 && to < oldpar.size())
                        ++from;
 
-               if (same_par && cur.pos() > from && cur.pos() < to)
+               if (same_par && cur.pos() >= from && cur.pos() < to)
                        ++from;
 
                // Remove spaces and adapt cursor.