From: Vincent van Ravesteijn Date: Wed, 26 Nov 2008 19:26:29 +0000 (+0000) Subject: Fix bug 5088: X-Git-Tag: 2.0.0~7627 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=39f6e4b898aace8c6d2a1fa9403470357b3e9688;p=features.git Fix bug 5088: http://bugzilla.lyx.org/show_bug.cgi?id=5088 After executing DEPM to remove a double space, the position of the cursor was only 'fixed' if the cursor remained in the same par. This patch corrects this to fix the position of the cursor also when the cursor is in a nested inset which is in the same par. This is needed because otherwise the cursor would not point to the inset but one pos after it. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@27715 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/Text2.cpp b/src/Text2.cpp index 9db9b76036..c078e38ea9 100644 --- a/src/Text2.cpp +++ b/src/Text2.cpp @@ -802,10 +802,18 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur, // delete the LineSeparator. // MISSING - bool const same_inset = &old.inset() == &cur.inset(); - bool const same_par = same_inset && old.pit() == cur.pit(); - bool const same_par_pos = same_par && old.pos() == cur.pos(); + // Find a common inset and the corresponding depth. + size_t depth = 0; + for (; depth < cur.depth(); ++depth) + if (&old.inset() == &cur[depth].inset()) + break; + // Whether a common inset is found and whether the cursor is still in + // the same paragraph (possibly nested). + bool same_par = depth < cur.depth() && old.pit() == cur[depth].pit(); + bool const same_par_pos = depth == cur.depth() - 1 && same_par + && old.pos() == cur[depth].pos(); + // If the chars around the old cursor were spaces, delete one of them. if (!same_par_pos) { // Only if the cursor has really moved. @@ -822,7 +830,7 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur, // automated way in CursorSlice code. (JMarc 26/09/2001) // correct all cursor parts if (same_par) { - fixCursorAfterDelete(cur.top(), old.top()); + fixCursorAfterDelete(cur[depth], old.top()); need_anchor_change = true; } return true;