* src/toc.C: allow upwards movement to first paragraph (bug 3131)

fix from Bernhard Roider.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17582 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2007-03-27 05:53:14 +00:00
parent d44b37a373
commit abe620d1ee

View File

@ -63,27 +63,24 @@ void outline(OutlineOp mode, LCursor & cur)
} }
ParagraphList::iterator dest = start; ParagraphList::iterator dest = start;
// Move out (up) from this header // Move out (up) from this header
if (dest != bgn) if (dest == bgn)
--dest;
else
break; break;
// Search previous same-level header above // Search previous same-level header above
for (; dest != bgn; --dest) { do {
--dest;
toclevel = dest->layout()->toclevel; toclevel = dest->layout()->toclevel;
if (toclevel != LyXLayout::NOT_IN_TOC } while(dest != bgn &&
&& toclevel <= thistoclevel) { (toclevel == LyXLayout::NOT_IN_TOC
break; || toclevel > thistoclevel));
}
}
// Not found; do nothing // Not found; do nothing
if (dest == bgn) if (toclevel == LyXLayout::NOT_IN_TOC || toclevel > thistoclevel)
break; break;
pit_type const newpit = std::distance(bgn, dest); pit_type const newpit = std::distance(bgn, dest);
pit_type const len = std::distance(start, finish); pit_type const len = std::distance(start, finish);
pit_type const deletepit = pit + len; pit_type const deletepit = pit + len;
recordUndo(cur, Undo::ATOMIC, newpit, deletepit - 1); recordUndo(cur, Undo::ATOMIC, newpit, deletepit - 1);
pars.insert(dest, start, finish); pars.insert(dest, start, finish);
start = boost::next(bgn, deletepit); start = boost::next(pars.begin(), deletepit);
pit = newpit; pit = newpit;
pars.erase(start, finish); pars.erase(start, finish);
break; break;
@ -117,7 +114,7 @@ void outline(OutlineOp mode, LCursor & cur)
// One such was found: // One such was found:
pit_type newpit = std::distance(bgn, dest); pit_type newpit = std::distance(bgn, dest);
pit_type const len = std::distance(start, finish); pit_type const len = std::distance(start, finish);
recordUndo(cur, Undo::ATOMIC, pit, newpit -1); recordUndo(cur, Undo::ATOMIC, pit, newpit - 1);
pars.insert(dest, start, finish); pars.insert(dest, start, finish);
start = boost::next(bgn, pit); start = boost::next(bgn, pit);
pit = newpit - len; pit = newpit - len;