]> git.lyx.org Git - features.git/commitdiff
Fix bug 3303 from Bernhard Roider. Some explanation:
authorAbdelrazak Younes <younes@lyx.org>
Mon, 5 Mar 2007 13:16:55 +0000 (13:16 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Mon, 5 Mar 2007 13:16:55 +0000 (13:16 +0000)
The problem was that pit is a reference to cur.pit() and was set to lastpit() + 1 before calling recordUndo(cur, ...). thus an invalid cursor position was stored in the undo buffer.
A side effect of the attached patch is that now the cursor keeps staying in the moved section header  on undo (which is not the case in current trunk)

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17410 a592a061-630c-0410-9148-cb99ea01b6c8

src/toc.C

index 26d537e2d5b0f1fb13efc9d4b6bfc97e60366bcb..0a441620324a0c55c32f84a07aa74c71a6f3f973 100644 (file)
--- a/src/toc.C
+++ b/src/toc.C
@@ -80,11 +80,10 @@ void outline(OutlineOp mode,  LCursor & cur)
                                break;
                        pit_type const newpit = std::distance(bgn, dest);
                        pit_type const len = std::distance(start, finish);
-                       pit += len;
-                       pit = std::min(pit, cur.lastpit());
-                       recordUndo(cur, Undo::ATOMIC, newpit, pit);
+                       pit_type const deletepit = pit + len;
+                       recordUndo(cur, Undo::ATOMIC, newpit, deletepit - 1);
                        pars.insert(dest, start, finish);
-                       start = boost::next(bgn, pit);
+                       start = boost::next(bgn, deletepit);
                        pit = newpit;
                        pars.erase(start, finish);
                break;