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.
This commit is contained in:
Enrico Forestieri 2014-05-22 21:47:10 +02:00
parent 52ebcd6280
commit 02e7bc18a7

View 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();