- // cursor.pos(cursor.pos() + 1);
-
- // break the paragraph
- if (keep_layout)
- keep_layout = 2;
- else
- keep_layout = layout.isEnvironment();
- cursor.par()->breakParagraph(bview->buffer()->params, cursor.pos(),
- keep_layout);
-
- // well this is the caption hack since one caption is really enough
- if (layout.labeltype == LABEL_SENSITIVE) {
- if (!cursor.pos())
- // set to standard-layout
- cursor.par()->applyLayout(tclass.defaultLayoutName());
- else
- // set to standard-layout
- cursor.par()->next()->applyLayout(tclass.defaultLayoutName());
- }
-
- /* if the cursor is at the beginning of a row without prior newline,
- * move one row up!
- * This touches only the screen-update. Otherwise we would may have
- * an empty row on the screen */
- if (cursor.pos() && !cursor.row()->par()->isNewline(cursor.row()->pos() - 1)
- && cursor.row()->pos() == cursor.pos())
- {
- cursorLeft(bview);
- }
-
- status(bview, LyXText::NEED_MORE_REFRESH);
- refresh_row = cursor.row();
- refresh_y = cursor.y() - cursor.row()->baseline();
-
- // Do not forget the special right address boxes
- if (layout.margintype == MARGIN_RIGHT_ADDRESS_BOX) {
- while (refresh_row->previous() &&
- refresh_row->previous()->par() == refresh_row->par()) {
- refresh_row = refresh_row->previous();
- refresh_y -= refresh_row->height();
- }
- }
- removeParagraph(cursor.row());
-
- // set the dimensions of the cursor row
- cursor.row()->fill(fill(bview, cursor.row(), workWidth(bview)));
-
- setHeightOfRow(bview, cursor.row());
-
- while (cursor.par()->next()->size()
+ // cursor.pos(cursor.pos() + 1);
+
+ // break the paragraph
+ if (keep_layout)
+ keep_layout = 2;
+ else
+ keep_layout = layout->isEnvironment();
+
+ // we need to set this before we insert the paragraph. IMO the
+ // breakParagraph call should return a bool if it inserts the
+ // paragraph before or behind and we should react on that one
+ // but we can fix this in 1.3.0 (Jug 20020509)
+ bool const isempty = (layout->keepempty && cursor.par()->empty());
+ ::breakParagraph(bview->buffer()->params, cursor.par(), cursor.pos(),
+ keep_layout);
+
+ // well this is the caption hack since one caption is really enough
+ if (layout->labeltype == LABEL_SENSITIVE) {
+ if (!cursor.pos())
+ // set to standard-layout
+ cursor.par()->applyLayout(tclass.defaultLayout());
+ else
+ // set to standard-layout
+ cursor.par()->next()->applyLayout(tclass.defaultLayout());
+ }
+
+ // if the cursor is at the beginning of a row without prior newline,
+ // move one row up!
+ // This touches only the screen-update. Otherwise we would may have
+ // an empty row on the screen
+ if (cursor.pos() && !cursor.row()->par()->isNewline(cursor.row()->pos() - 1)
+ && cursor.row()->pos() == cursor.pos())
+ {
+ cursorLeft(bview);
+ }
+
+ status(bview, LyXText::NEED_MORE_REFRESH);
+ refresh_row = cursor.row();
+ refresh_y = cursor.y() - cursor.row()->baseline();
+
+ // Do not forget the special right address boxes
+ if (layout->margintype == MARGIN_RIGHT_ADDRESS_BOX) {
+ while (refresh_row->previous() &&
+ refresh_row->previous()->par() == refresh_row->par())
+ {
+ refresh_row = refresh_row->previous();
+ refresh_y -= refresh_row->height();
+ }
+ }
+ removeParagraph(cursor.row());
+
+ // set the dimensions of the cursor row
+ cursor.row()->fill(fill(bview, cursor.row(), workWidth(bview)));
+
+ setHeightOfRow(bview, cursor.row());
+
+ while (!cursor.par()->next()->empty()