From: Abdelrazak Younes Date: Mon, 21 Apr 2008 08:22:52 +0000 (+0000) Subject: Fix some outline bugs: X-Git-Tag: 1.6.10~5065 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=61c4dc2af85cb8b8130303fd9ff3f47409bb7e9f;p=features.git Fix some outline bugs: 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 --- diff --git a/src/Text3.cpp b/src/Text3.cpp index 9e8ce03dd8..b8d2dd3988 100644 --- a/src/Text3.cpp +++ b/src/Text3.cpp @@ -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);