The attached patch fixes this. The problem was that outline(UP) stopped as soon as the destination was the first paragraph in the document, which is a very valid position for headings, though.
I had to fiddle with pit/deletepit in this case (else, the moved paragraph was not erased). Martin, Bernhard, could you have a look whether this makes sense? Jürgen
Index: src/toc.C =================================================================== --- src/toc.C (Revision 17526) +++ src/toc.C (Arbeitskopie) @@ -76,14 +76,18 @@ } } // Not found; do nothing - if (dest == bgn) + if (dest == bgn && + dest->layout()->toclevel == LyXLayout::NOT_IN_TOC) break; pit_type const newpit = std::distance(bgn, dest); pit_type const len = std::distance(start, finish); pit_type const deletepit = pit + len; recordUndo(cur, Undo::ATOMIC, newpit, deletepit - 1); pars.insert(dest, start, finish); - start = boost::next(bgn, deletepit); + if (dest == bgn) + start = boost::next(bgn, pit); + else + start = boost::next(bgn, deletepit); pit = newpit; pars.erase(start, finish); break; @@ -117,7 +121,7 @@ // One such was found: pit_type newpit = std::distance(bgn, dest); 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); start = boost::next(bgn, pit); pit = newpit - len;