Oops... forgot to send to the list ;-) ----- Forwarded message from Martin Vermeer <[EMAIL PROTECTED]> -----
X-Authentication-Warning: geo9.hut.fi: mv set sender to [EMAIL PROTECTED] using -f Date: Tue, 29 Jan 2002 11:02:31 +0200 From: Martin Vermeer <[EMAIL PROTECTED]> To: Martin Vermeer <[EMAIL PROTECTED]> Cc: Angus Leeming <[EMAIL PROTECTED]> Subject: FIX: unlimited environment depth bug User-Agent: Mutt/1.2.5.1i In-Reply-To: <[EMAIL PROTECTED]>; from [EMAIL PROTECTED] on Tue, Jan 29, 2002 at 09:32:29AM +0200 X-Operating-System: Linux geo9.hut.fi 2.2.14-5.0 X-SpamBouncer: 1.4 (10/07/01) X-SBPass: No Freemail Filtering X-SBClass: OK 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()) ----- End forwarded message ----- -- Martin Vermeer [EMAIL PROTECTED] Helsinki University of Technology Department of Surveying P.O. Box 1200, FIN-02015 HUT, Finland :wq
msg32121/pgp00000.pgp
Description: PGP signature