]> git.lyx.org Git - lyx.git/blobdiff - src/Text3.cpp
Fix #10328.
[lyx.git] / src / Text3.cpp
index f290ca690c8f62ead95e1aa9550ad42e8ba634c7..313be9d88c052dd8da1c22b72489fe6589c845a6 100644 (file)
@@ -384,7 +384,7 @@ static void outline(OutlineOp mode, Cursor & cur, Text * text)
        ParagraphList & pars = buf.text().paragraphs();
        ParagraphList::iterator const bgn = pars.begin();
        // The first paragraph of the area to be copied:
-       ParagraphList::iterator start = lyx::next(bgn, pit);
+       ParagraphList::iterator start = pars.iterator_at(pit);
        // The final paragraph of area to be copied:
        ParagraphList::iterator finish = start;
        ParagraphList::iterator const end = pars.end();
@@ -962,7 +962,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                ParagraphList & pars = buf.text().paragraphs();
                ParagraphList::iterator bgn = pars.begin();
                // The first paragraph of the area to be selected:
-               ParagraphList::iterator start = lyx::next(bgn, pit);
+               ParagraphList::iterator start = pars.iterator_at(pit);
                // The final paragraph of area to be selected:
                ParagraphList::iterator finish = start;
                ParagraphList::iterator end = pars.end();
@@ -1588,8 +1588,13 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                if (change_layout) {
                        setLayout(cur, layout);
                        if (cur.pit() > 0 && !ignoreautonests) {
+                               pit_type prev_pit = cur.pit() - 1;
+                               depth_type const cur_depth = pars_[cur.pit()].getDepth();
+                               // Scan for the previous par on same nesting level
+                               while (prev_pit > 0 && pars_[prev_pit].getDepth() > cur_depth)
+                                       --prev_pit;
                                set<docstring> const & autonests =
-                                               pars_[cur.pit() - 1].layout().autonests();
+                                               pars_[prev_pit].layout().autonests();
                                set<docstring> const & autonested =
                                                pars_[cur.pit()].layout().isAutonestedBy();
                                if (autonests.find(layout) != autonests.end()
@@ -3060,7 +3065,6 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
                        cur.buffer()->params().documentClass().insetLayout(from_utf8(s));
                if (il.lyxtype() != InsetLayout::CHARSTYLE &&
                    il.lyxtype() != InsetLayout::CUSTOM &&
-                   il.lyxtype() != InsetLayout::ELEMENT &&
                    il.lyxtype ()!= InsetLayout::STANDARD)
                        enable = false;
                break;