]> git.lyx.org Git - lyx.git/blobdiff - src/text2.C
Fixed cut&paste bugs and added freespacing for ERT Insets.
[lyx.git] / src / text2.C
index 5d95dc2172ee4320f0b9be0a50ba26f6bd7eff79..0c092dff9a053ace05a83a13e0f4d6d0990dc799 100644 (file)
@@ -49,6 +49,7 @@ using std::find;
 using std::endl;
 using std::find;
 using std::pair;
+using lyx::pos_type;
 
 
 LyXText::LyXText(BufferView * bv)
@@ -390,6 +391,7 @@ void LyXText::removeRow(Row * row) const
                row->next()->previous(row->previous());
        if (!row->previous()) {
                firstrow = row->next();
+//             lyx::Assert(firstrow);
        } else  {
                row->previous()->next(row->next());
        }
@@ -498,7 +500,7 @@ void LyXText::makeFontEntriesLayoutSpecific(Buffer const * buf,
 Paragraph * LyXText::setLayout(BufferView * bview,
                               LyXCursor & cur, LyXCursor & sstart_cur,
                               LyXCursor & send_cur,
-                              layout_type layout)
+                              lyx::layout_type layout)
 {
        Paragraph * endpar = send_cur.par()->next();
        Paragraph * undoendpar = endpar;
@@ -560,7 +562,7 @@ Paragraph * LyXText::setLayout(BufferView * bview,
 
 
 // set layout over selection and make a total rebreak of those paragraphs
-void LyXText::setLayout(BufferView * bview, layout_type layout)
+void LyXText::setLayout(BufferView * bview, lyx::layout_type layout)
 {
        LyXCursor tmpcursor = cursor;  /* store the current cursor  */
 
@@ -1163,7 +1165,7 @@ string LyXText::getStringToIndex(BufferView * bview)
 }
 
 
-LyXText::pos_type LyXText::beginningOfMainBody(Buffer const * buf,
+pos_type LyXText::beginningOfMainBody(Buffer const * buf,
                             Paragraph const * par) const
 {
        if (textclasslist.Style(buf->params.textclass,
@@ -2365,13 +2367,20 @@ void LyXText::fixCursorAfterDelete(BufferView * bview,
 void LyXText::deleteEmptyParagraphMechanism(BufferView * bview,
                                            LyXCursor const & old_cursor) const
 {
+       // don't delete anything if this is the ONLY paragraph!
+       if (!old_cursor.par()->next() && !old_cursor.par()->previous())
+               return;
+       
        // Would be wrong to delete anything if we have a selection.
        if (selection.set()) return;
 
        // We allow all kinds of "mumbo-jumbo" when freespacing.
        if (textclasslist.Style(bview->buffer()->params.textclass,
-                               old_cursor.par()->getLayout()).free_spacing)
+                                                       old_cursor.par()->getLayout()).free_spacing ||
+               old_cursor.par()->isFreeSpacing())
+       {
                return;
+       }
 
        bool deleted = false;