commit 02e7bc18a7bb03a2799d98353adafe036e4fb340
Author: Enrico Forestieri <for...@lyx.org>
Date:   Thu May 22 21:47:10 2014 +0200

    Simplify the test for inserting a parbreak separator.
    
    Instead of simply taking into account the layout of the previous
    paragraph, it is better considering the layout of the environment
    in which the previous paragraph may be nested. This makes the test
    simpler and, at the same time, more robust.

diff --git a/src/Text3.cpp b/src/Text3.cpp
index 31e0826..707a4e2 100644
--- a/src/Text3.cpp
+++ b/src/Text3.cpp
@@ -1071,14 +1071,14 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                cap::replaceSelection(cur);
                pit_type pit = cur.pit();
                Paragraph const & par = pars_[pit];
-               Paragraph const & prevpar = pit > 0 ? pars_[pit - 1] : par;
-               if (pit > 0 && cur.pos() == par.beginOfBody()
+               pit_type prev =
+                       pit > 0 && pars_[pit - 1].getDepth() >= par.getDepth() ?
+                       depthHook(pit, par.getDepth()) : pit;
+               if (prev < pit && cur.pos() == par.beginOfBody()
                    && !par.isEnvSeparator(cur.pos())
                    && !par.layout().isCommand()
-                   && ((prevpar.getDepth() > par.getDepth()
-                        && !par.layout().isEnvironment())
-                       || (prevpar.layout() != par.layout()
-                           && prevpar.layout().isEnvironment()))) {
+                   && pars_[prev].layout() != par.layout()
+                   && pars_[prev].layout().isEnvironment()) {
                        if (par.layout().isEnvironment()) {
                                docstring const layout = par.layout().name();
                                DocumentClass const & tc = 
bv->buffer().params().documentClass();

Reply via email to