From: Juergen Spitzmueller Date: Sat, 21 Oct 2023 11:48:50 +0000 (+0200) Subject: Let OUTLINE functions jump from section to part if there is no chapter X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=2b33da5944c3a3ec59821a63e930450777f88fa4;p=features.git Let OUTLINE functions jump from section to part if there is no chapter Fixes #12938 --- diff --git a/src/Text.cpp b/src/Text.cpp index ef5dd26615..820b755511 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -3903,8 +3903,20 @@ void outline(OutlineOp mode, Cursor & cur, bool local) continue; DocumentClass const & tc = buf.params().documentClass(); - int const newtoclevel = - (mode == OutlineIn ? toclevel + 1 : toclevel - 1); + int newtoclevel = -1; + if (mode == OutlineIn) { + if (toclevel == -1 && tc.getTOCLayout().toclevel > 0) + // we are at part but don't have a chapter + newtoclevel = tc.getTOCLayout().toclevel; + else + newtoclevel = toclevel + 1; + } else { + if (tc.getTOCLayout().toclevel == toclevel && tc.min_toclevel() < toclevel) + // we are at highest level, but there is still part + newtoclevel = tc.min_toclevel(); + else + newtoclevel = toclevel - 1; + } bool found = false; for (auto const & lay : tc) { @@ -3939,8 +3951,20 @@ void outline(OutlineOp mode, Cursor & cur, bool local) continue; DocumentClass const & tc = buf.params().documentClass(); - int const newtoclevel = - (mode == OutlineIn ? toclevel + 1 : toclevel - 1); + int newtoclevel = -1; + if (mode == OutlineIn) { + if (toclevel == -1 && tc.getTOCLayout().toclevel > 0) + // we are at part but don't have a chapter + newtoclevel = tc.getTOCLayout().toclevel; + else + newtoclevel = toclevel + 1; + } else { + if (tc.getTOCLayout().toclevel == toclevel && tc.min_toclevel() < toclevel) + // we are at highest level, but there is still part + newtoclevel = tc.min_toclevel(); + else + newtoclevel = toclevel - 1; + } for (auto const & lay : tc) { if (lay.toclevel == newtoclevel