]> git.lyx.org Git - features.git/commitdiff
Fix some outline bugs:
authorAbdelrazak Younes <younes@lyx.org>
Mon, 21 Apr 2008 08:22:52 +0000 (08:22 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Mon, 21 Apr 2008 08:22:52 +0000 (08:22 +0000)
http://bugzilla.lyx.org/show_bug.cgi?id=4686
http://bugzilla.lyx.org/show_bug.cgi?id=4703

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

src/Text3.cpp

index 9e8ce03dd8acee195c4d042e7fc2534f9a973100..b8d2dd398815b61b504a40bdb59b30daf20d6cf8 100644 (file)
@@ -286,6 +286,9 @@ static void outline(OutlineOp mode, Cursor & cur)
 
        switch (mode) {
                case OutlineUp: {
+                       if (start == pars.begin())
+                               // Nothing to move.
+                               return;
                        ParagraphList::iterator dest = start;
                        // Move out (up) from this header
                        if (dest == bgn)
@@ -311,10 +314,22 @@ static void outline(OutlineOp mode, Cursor & cur)
                        return;
                }
                case OutlineDown: {
-                       ParagraphList::iterator dest = finish;
+                       if (finish == end)
+                               // Nothing to move.
+                               return;
+                       // Go one down from *this* header:
+                       ParagraphList::iterator dest = boost::next(finish, 1);
+                       // Go further down to find header to insert in front of:
+                       for (; dest != end; ++dest) {
+                               toclevel = dest->layout().toclevel;
+                               if (toclevel != Layout::NOT_IN_TOC
+                                   && toclevel <= thistoclevel) {
+                                       break;
+                               }
+                       }
                        // One such was found:
-                       pit_type newpit = distance(bgn, dest);
-                       pit_type const len = distance(start, finish);
+                       pit_type newpit = std::distance(bgn, dest);
+                       pit_type const len = std::distance(start, finish);
                        buf.undo().recordUndo(cur, ATOMIC_UNDO, pit, newpit - 1);
                        pars.insert(dest, start, finish);
                        start = boost::next(bgn, pit);