]> git.lyx.org Git - lyx.git/blobdiff - src/text.C
fix crash when collapsing ert with cursor inside
[lyx.git] / src / text.C
index 1753cea13fabf6b402d5a3b2e5f9dfe7d1fac0a2..18c6df2476fc9f6cdb6fb1d6e29e4684bd6774f5 100644 (file)
@@ -591,7 +591,7 @@ int LyXText::leftMargin(pit_type const pit, pos_type const pos) const
            && align == LYX_ALIGN_BLOCK
            && !par.params().noindent()
            // in charstyles, tabulars and ert paragraphs are never indented!
-           && (par.ownerCode() != InsetBase::TEXT_CODE
+           && ((par.ownerCode() != InsetBase::TEXT_CODE || isMainText())
                    && par.ownerCode() != InsetBase::ERT_CODE
                    && par.ownerCode() != InsetBase::CHARSTYLE_CODE)
            && (par.layout() != tclass.defaultLayout()
@@ -1654,6 +1654,23 @@ void LyXText::redoParagraph(pit_type const pit)
        // remove rows of paragraph, keep track of height changes
        Paragraph & par = pars_[pit];
 
+       // Add bibitem insets if necessary
+       if (par.layout()->labeltype == LABEL_BIBLIO) {
+               bool hasbibitem(false);
+               if (!par.insetlist.empty() 
+                       // Insist on it being in pos 0
+                       && par.getChar(0) == Paragraph::META_INSET) {
+                       InsetBase * inset = par.insetlist.begin()->inset;
+                       if (inset->lyxCode() == InsetBase::BIBITEM_CODE)
+                               hasbibitem = true;
+               }
+               if (!hasbibitem) {
+                       InsetBibitem * inset(new
+                               InsetBibitem(InsetCommandParams("bibitem")));
+                       par.insertInset(0, static_cast<InsetBase *>(inset));
+               }
+       }
+
        // redo insets
        InsetList::iterator ii = par.insetlist.begin();
        InsetList::iterator iend = par.insetlist.end();