]> git.lyx.org Git - features.git/commitdiff
Maintain nesting when separating outer environment
authorJuergen Spitzmueller <spitz@lyx.org>
Sat, 30 Dec 2017 17:54:39 +0000 (18:54 +0100)
committerJuergen Spitzmueller <spitz@lyx.org>
Sat, 30 Dec 2017 17:54:39 +0000 (18:54 +0100)
src/Text3.cpp

index 8d37e790b3ff6c8594675957e2e7757f255a1a9a..a65de1d7514d31bf4e39702e2071aa97f16a134a 100644 (file)
@@ -1510,6 +1510,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                if (para.layout().isEnvironment())
                        layout = para.layout().name();
                depth_type split_depth = cur.paragraph().params().depth();
+               depth_type nextpar_depth = 0;
                if (outer || previous) {
                        // check if we have an environment in our scope
                        pit_type pit = cur.pit();
@@ -1532,6 +1533,11 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                                if (cpar.params().depth() == 0)
                                        break;
                        }
+                       if (outer && pit < cur.lastpit()) {
+                               // save nesting of following paragraph
+                               cpar = pars_[cur.pit() + 1];
+                               nextpar_depth = cpar.params().depth();
+                       }
                }
                if (before)
                        cur.top().setPitPos(cur.pit(), 0);
@@ -1556,6 +1562,14 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                else
                        lyx::dispatch(FuncRequest(LFUN_PARAGRAPH_BREAK, "inverse"));
                lyx::dispatch(FuncRequest(LFUN_LAYOUT, layout));
+               if (outer && nextpar_depth > 0) {
+                       // restore nesting of following paragraph
+                       DocIterator scur = cur;
+                       cur.forwardPar();
+                       while (cur.paragraph().params().depth() < nextpar_depth)
+                               lyx::dispatch(FuncRequest(LFUN_DEPTH_INCREMENT));
+                       cur.setCursor(scur);
+               }
 
                break;
        }