]> git.lyx.org Git - features.git/commitdiff
Simplify the test for inserting a parbreak separator.
authorEnrico Forestieri <forenr@lyx.org>
Thu, 22 May 2014 19:47:10 +0000 (21:47 +0200)
committerEnrico Forestieri <forenr@lyx.org>
Thu, 22 May 2014 19:47:10 +0000 (21:47 +0200)
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.

src/Text3.cpp

index 31e082644c28e89d60e080576e52cab06fd16462..707a4e204dec6b784f389567913a3e6dac56bdc9 100644 (file)
@@ -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();