]> git.lyx.org Git - lyx.git/blobdiff - src/Text3.cpp
Fix #10328.
[lyx.git] / src / Text3.cpp
index 238736b126a8bd31c0a5e4871905c19b0cf9c683..313be9d88c052dd8da1c22b72489fe6589c845a6 100644 (file)
@@ -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;