On Wed, Oct 19, 2016 at 02:53:43PM +0200, Jean-Marc Lasgouttes wrote:
> Le 19/10/2016 à 14:30, Jean-Marc Lasgouttes a écrit :
> >>Tested and I think there is a minor issue. In the attached .lyx file,
> >>put the cursor at the end of "hello". Press return three times. The
> >>first two times show that the issue initially reported is fixed (because
> >>it is itemize instead of enumerate), but the third return is unexpected
> >>for me. I expected it to go out of itemize, but instead it created an
> >>item with a separator.
> >>
> >>Can you reproduce the above with your patch?
> >
> >I see what you mean. I guess that I am colliding somehow with the logic
> >that introduces separator insets.
> 
> There is some kind of Clash beween the logic here and Enrico's logic wrt
> paragraph separators.
> 
> Here I am in a logic where using Return in an empty environment will signal
> that I want to close it and go to the uspper level.
> 
> Enrico's code, OTOH assumes that what is meant here is to split the
> environment in two but stay at the same level. I do not see why my patch
> made Enrico's code trigger. Well, I see it technically, but I do not see
> what sense it makes.
> 
> Enrico, do you have thoughts about what we really want there? What is the
> use case that we have in mind, especially when we are in a nested
> environment?

I had a look and it turns out that the code dealing with separator
insets was specifically tailored to the old behaviour. If you change
that behaviour, you should also change the corresponding separator code.
This is what the attached patch does. It must be applied if your patch
is applied, otherwise not.

Anyway, the previous behaviour was really strange and indeed also
the code to be changed for introducing a separator simplifies, as
you can see.

-- 
Enrico
diff --git a/src/Text3.cpp b/src/Text3.cpp
index eafce28..85d0c3c 100644
--- a/src/Text3.cpp
+++ b/src/Text3.cpp
@@ -1089,13 +1089,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                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())
-                               prev = depthHook(pit, par.getDepth());
-                       else if (pars_[pit - 1].getDepth() >= par.getDepth())
-                               prev = pit - 1;
-               }
+               pit_type prev = pit > 0 ? depthHook(pit, par.getDepth()) : pit;
                if (prev < pit && cur.pos() == par.beginOfBody()
                    && !par.size() && !par.isEnvSeparator(cur.pos())
                    && !par.layout().isCommand()

Reply via email to