]> git.lyx.org Git - features.git/commitdiff
When breaking an empty paragraph reduces depth, set layout too
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 13 Oct 2016 18:33:57 +0000 (20:33 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 20 Oct 2016 12:50:34 +0000 (14:50 +0200)
This requires an adaptation of the Separator inset insertion code,
which has been duly provided by Enrico.
(cherry picked from commit b162bd6d2b4284d02d7f4ce5883ae4bef3880883)

src/Text.cpp
src/Text3.cpp

index a6176bc08ac09e0648c55016239d1eab569bf2c7..36d0decf73aa48991134c62e88a7a115001d1f41 100644 (file)
@@ -764,9 +764,13 @@ void Text::breakParagraph(Cursor & cur, bool inverse_logic)
        Layout const & layout = cpar.layout();
 
        if (cur.lastpos() == 0 && !cpar.allowEmpty()) {
-               if (changeDepthAllowed(cur, DEC_DEPTH))
+               if (changeDepthAllowed(cur, DEC_DEPTH)) {
                        changeDepth(cur, DEC_DEPTH);
-               else {
+                       pit_type const prev = depthHook(cpit, cpar.getDepth());
+                       docstring const & lay = pars_[prev].layout().name();
+                       if (lay != layout.name())
+                               setLayout(cur, lay);
+               } else {
                        docstring const & lay = cur.paragraph().usePlainLayout()
                            ? tclass.plainLayoutName() : tclass.defaultLayoutName();
                        if (lay != layout.name())
index bfb5d7953eff2918eb1dfae0e5fca1cd44223436..45cc7637c5fafc65727319e77a1a14c27972b889 100644 (file)
@@ -1088,13 +1088,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                Paragraph const & par = pars_[pit];
                bool lastpar = (pit == pit_type(pars_.size() - 1));
                Paragraph const & nextpar = lastpar ? par : pars_[pit + 1];
-               pit_type prev = pit;
-               if (pit > 0) {
-                       if (!pars_[pit - 1].layout().isEnvironment())
-                               prev = depthHook(pit, par.getDepth());
-                       else if (pars_[pit - 1].getDepth() >= par.getDepth())
-                               prev = pit - 1;
-               }
+               pit_type prev = pit > 0 ? depthHook(pit, par.getDepth()) : pit;
                if (prev < pit && cur.pos() == par.beginOfBody()
                    && !par.size() && !par.isEnvSeparator(cur.pos())
                    && !par.layout().isCommand()