[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lyx-devel
Subject:    Re: r30766 - lyx-devel/trunk/src
From:       Enrico Forestieri <forenr () lyx ! org>
Date:       2009-07-30 3:09:53
Message-ID: 20090730030953.GA12121 () sirio ! sssup ! it
[Download RAW message or body]


On Wed, Jul 29, 2009 at 01:34:45PM +0200, Jürgen Spitzmüller wrote:

> Enrico Forestieri wrote:
> > I was still able to find cases where it would fail. Looking more closely at
> > the code, it was clear that a similar treatment should have also been
> > performed in TeXEnvironment(). After careful testing, I have committed a
> > fix to trunk that doesn't fail for all the contrived examples I devised. I
> > think it should also go to branch. Attached find some examples where it was
> > still failing.
> 
> go on.

I committed a simpler patch that in addition should be fail proof. Indeed,
when an environment ends, it simply records the language that was in effect
at the start of the environment itself, and then use this as the previous
language in effect when the environment is switched and the previous one
was nested deeper, or it was at the same nesting depth but with a different
layout.

Note that in some cases a redundant switch could occur. However, this is a
fault of the following (already existing) code that tries to guess whether
the language was already switched in TeXEnvironment():

	if (par_language->babel() != prev_language->babel()
	    // check if we already put language command in TeXEnvironment()
	    && !(style.isEnvironment()
		 && (pit == paragraphs.begin() ||
		     (priorpit->layout() != pit->layout() &&
		      priorpit->getDepth() <= pit->getDepth())
		     || priorpit->getDepth() < pit->getDepth())))

As can be seen, it assumes that the language has not to be switched if the
previous paragraph is in an environment with a lower nesting depth, or with
same depth but with different layout. So, when the previous paragraph has a
higher nesting depth, a language switch is always performed *inside* the
environment. This would be correct only if the current paragraph is in the
same environment in which the previous one is nested. However, this cannot
be determined by simply looking at the previous paragraph, because there is
no way to know what is the nesting environment. One should go back to a
paragraph with a depth equal to the current one in order to know.

I attach an example document showing this problem. In the last environment
you can see a redundant switch. It disappears if the Quotation is turned
into the Quote environment (i.e., the environment in which the previous one
is nested). I think that it is not worth complicating the code above for
avoiding a possible redundant switch, and would leave it as it is now.

-- 
Enrico

["redundant-switch.lyx" (application/x-lyx)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic