I don't think I'm knowledgable enough about this, people. For those who are, try this.
Angus ---------- Forwarded Message ---------- Subject: FIX: unlimited environment depth bug Date: Tue, 29 Jan 2002 11:02:31 +0200 From: Martin Vermeer <[EMAIL PROTECTED]> To: Martin Vermeer <[EMAIL PROTECTED]> Cc: Angus Leeming <[EMAIL PROTECTED]> On Tue, Jan 29, 2002 at 09:32:29AM +0200, Martin Vermeer wrote: > > Here's another interesting one: there is no limit on the environment > depth one can create. Sure it works OK on LaTeX output, but do we really > want to allow this? > > Also I don't see how one easily resets the environment depth of > a paragraph. Under the old system, it would cycle back to zero. Now I > have to change the previous paragraph back to Standard to do it. Not > nice. > > -- Martin Here's the fix. Seems a simple C syntax thing and as usual, a little mysterious. I added some comments for the edification of the next visitor to this code as well. Please apply. -- Martin -------------------------------------------------------
Index: text2.C =================================================================== RCS file: /cvs/lyx/lyx-devel/src/text2.C,v retrieving revision 1.197 diff -u -b -B -p -r1.197 text2.C --- text2.C 2002/01/18 03:50:19 1.197 +++ text2.C 2002/01/29 08:51:27 @@ -641,13 +641,18 @@ void LyXText::incDepth(BufferView * bvi ).labeltype != LABEL_BIBLIO) { Paragraph * prev = cursor.par()->previous(); - if (prev - && (prev->getDepth() - cursor.par()->getDepth() > 0 - || (prev->getDepth() == cursor.par()->getDepth() + if (prev) { + int depth_diff = prev->getDepth() - +cursor.par()->getDepth(); + // go deeper only if + // (1) the previous para is already deeper (depth_diff +> 0) + // (2) the previous para is a list-environment at the + // same depth as this para. + if (depth_diff > 0 || (depth_diff > -1 && textclasslist.Style(bview->buffer()->params.textclass, - prev->getLayout()).isEnvironment()))) { + +prev->getLayout()).isEnvironment())) { cursor.par()->params().depth(cursor.par()->params().depth() + 1); anything_changed = true; + } } } if (cursor.par() == selection.end.par())
2
Description: PGP signature