From 02e7bc18a7bb03a2799d98353adafe036e4fb340 Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Thu, 22 May 2014 21:47:10 +0200 Subject: [PATCH] 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. --- src/Text3.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Text3.cpp b/src/Text3.cpp index 31e082644c..707a4e204d 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(); -- 2.39.2