On Sat, Dec 12, 2015 at 12:34:47AM +0000, Guillaume Munch wrote:
> Le 11/12/2015 22:47, Enrico Forestieri a écrit :
> >On Fri, Dec 11, 2015 at 06:52:19PM +0000, Guillaume Munch wrote:
[...]
> >>• Defect: They tend to accumulate and they are redundant because there
> >>   is only one additional '\n' in the LaTeX source. The problem is the
> >>   one can add one before another. Thus, two such consecutive chars
> >>   should be merged as a single one, like it is done for spaces in LyX.
> >
> >There were a lot of problems to be solved and this one was escaping me.
> >Thank you for pointing it out. I will try to address it when I will find
> >time (and motivation) to work again on LyX. Unfortunately, I will be
> >unavailable the next weeks.
> 
> Thanks.

The attached patch avoids the proliferation of parbreak seaparators.

-- 
Enrico
diff --git a/src/Text3.cpp b/src/Text3.cpp
index 9edda1b..ca6ec5b 100644
--- a/src/Text3.cpp
+++ b/src/Text3.cpp
@@ -1097,6 +1097,8 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
 		cap::replaceSelection(cur);
 		pit_type pit = cur.pit();
 		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())
@@ -1105,10 +1107,13 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
 				prev = pit - 1;
 		}
 		if (prev < pit && cur.pos() == par.beginOfBody()
-		    && !par.isEnvSeparator(cur.pos())
+		    && !par.isEnvSeparator(par.size() ? par.size() - 1 : 0)
 		    && !par.layout().isCommand()
 		    && pars_[prev].layout() != par.layout()
-		    && pars_[prev].layout().isEnvironment()) {
+		    && pars_[prev].layout().isEnvironment()
+		    && (!nextpar.isEnvSeparator(nextpar.size() ? nextpar.size() - 1 : 0)
+			    || nextpar.layout().isCommand()
+			    || nextpar.layout().isEnvironment())) {
 			if (par.layout().isEnvironment()
 			    && pars_[prev].getDepth() == par.getDepth()) {
 				docstring const layout = par.layout().name();
@@ -1124,6 +1129,8 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
 			Font const f(inherit_font, cur.current_font.language());
 			pars_[cur.pit() - 1].resetFonts(f);
 		} else {
+			if (par.isEnvSeparator(cur.pos()))
+				cur.posForward();
 			breakParagraph(cur, cmd.argument() == "inverse");
 		}
 		cur.resetAnchor();

Reply via email to