]> 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 be22fb835d3337b12037293ef62c0eeca3afedd6..4baf4a27f047e4b53b1258e89e745aad4173d2de 100644 (file)
@@ -1149,6 +1149,13 @@ void LyXText::breakParagraph(LCursor & cur, bool keep_layout)
                        Change(Change::INSERTED));
        }
 
+       // FIXME: Breaking a paragraph 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 setCursor() call below.
+       redoParagraph(cur.bv(), cpit);
+       redoParagraph(cur.bv(), cpit + 1);
+
        // This check is necessary. Otherwise the new empty paragraph will
        // be deleted automatically. And it is more friendly for the user!
        if (cur.pos() != 0 || isempty)
@@ -1242,6 +1249,11 @@ void LyXText::insertChar(LCursor & cur, char_type c)
        }
 
        par.insertChar(cur.pos(), c, current_font, cur.buffer().params().trackChanges);
+
+       // FIXME: Inserting a character 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.
+       redoParagraph(cur.bv(), cur.pit());
        setCursor(cur, cur.pit(), cur.pos() + 1, false, cur.boundary());
        charInserted();
 }
@@ -1660,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;
 }
@@ -1764,6 +1782,11 @@ bool LyXText::backspace(LCursor & cur)
        if (cur.pos() == cur.lastpos())
                setCurrentFont(cur);
 
+       // FIXME: Backspacing 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 setCursor() call.
+       redoParagraph(cur.bv(), cur.pit());
        setCursor(cur, cur.pit(), cur.pos(), false, cur.boundary());
 
        return needsUpdate;
@@ -1776,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
@@ -1793,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