diff --git a/src/ChangeLog b/src/ChangeLog index cc9a184b92..9c1408d375 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2002-02-26 Martin Vermeer + + * text2.C (incDepth): make sure depth cannot be increased beyond + reasonable values. + 2002-02-20 Angus Leeming * lyxfunc.C (dispatch): act on LFUN_FORKS_SHOW and LFUN_FORKS_KILL. diff --git a/src/text2.C b/src/text2.C index f83a41fbde..d97b44c865 100644 --- a/src/text2.C +++ b/src/text2.C @@ -649,19 +649,25 @@ void LyXText::incDepth(BufferView * bview) while (true) { // NOTE: you can't change the depth of a bibliography entry - if ( - textclasslist.Style(bview->buffer()->params.textclass, - cursor.par()->getLayout() - ).labeltype != LABEL_BIBLIO) { + if (textclasslist.Style(bview->buffer()->params.textclass, + cursor.par()->getLayout()).labeltype != LABEL_BIBLIO) { Paragraph * prev = cursor.par()->previous(); - if (prev - && (prev->getDepth() - cursor.par()->getDepth() > 0 - || (prev->getDepth() == cursor.par()->getDepth() + if (prev) { + const 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()))) { - cursor.par()->params().depth(cursor.par()->params().depth() + 1); - anything_changed = true; + prev->getLayout()).isEnvironment())) { + cursor.par()->params().depth(cursor.par()->params().depth() + 1); + anything_changed = true; + } } } if (cursor.par() == selection.end.par())