]> git.lyx.org Git - lyx.git/blobdiff - src/text.C
* LyXText::erase(): make sure the paragraph breaking is up to date. This might be...
[lyx.git] / src / text.C
index 674b7103f16c146a25b47e9055825379d873104b..4baf4a27f047e4b53b1258e89e745aad4173d2de 100644 (file)
@@ -1672,8 +1672,14 @@ bool LyXText::erase(LCursor & cur)
                needsUpdate = dissolveInset(cur);
 
        // Make sure the cursor is correct. Is this really needed?
-       if (needsUpdate)
+       // FIXME: Inserting characters has nothing to do with setting a cursor.
+       // Because of the mix between the model (the paragraph contents)
+       // and the view (the paragraph breaking in rows, we have to do this
+       // here before the setCursorIntern() call.
+       if (needsUpdate) {
+               redoParagraph(cur.bv(), cur.pit());
                setCursorIntern(cur, cur.pit(), cur.pos());
+       }
        
        return needsUpdate;
 }
@@ -1793,6 +1799,7 @@ bool LyXText::dissolveInset(LCursor & cur) {
        if (isMainText(*cur.bv().buffer()) || cur.inset().nargs() != 1)
                return false;
 
+       bool const in_ert = cur.inset().lyxCode() == InsetBase::ERT_CODE;
        recordUndoInset(cur);
        cur.selHandle(false);
        // save position
@@ -1810,6 +1817,19 @@ bool LyXText::dissolveInset(LCursor & cur) {
        // FIXME: change tracking (MG)
        cur.paragraph().eraseChar(cur.pos(), b.params().trackChanges);
        if (!plist.empty()) {
+               if (in_ert) {
+                       // ERT paragraphs have the Language latex_language.
+                       // This is invalid outside of ERT, so we need to
+                       // change it to the buffer language.
+                       ParagraphList::iterator it = plist.begin();
+                       ParagraphList::iterator it_end = plist.end();
+                       for (; it != it_end; it++) {
+                               it->changeLanguage(b.params(),
+                                               latex_language,
+                                               b.getLanguage());
+                       }
+               }
+
                pasteParagraphList(cur, plist, b.params().textclass,
                                   b.errorList("Paste"));
                // restore position