]> git.lyx.org Git - lyx.git/blobdiff - src/Text.cpp
Replace the hardcoded TEXT_TO_INSET_OFFSET by tunable values
[lyx.git] / src / Text.cpp
index 5e06fdccd1cb1a163c3cd06cf4da2719b1a48e6f..dc296384b266a22f76fecdd688677d12ccd1f048 100644 (file)
@@ -1370,7 +1370,7 @@ void Text::acceptOrRejectChanges(Cursor & cur, ChangeOp op)
        pos_type endPos = cur.selectionEnd().pos();
 
        // keep selection info, because endPos becomes invalid after the first loop
-       bool endsBeforeEndOfPar = (endPos < pars_[endPit].size());
+       bool const endsBeforeEndOfPar = (endPos < pars_[endPit].size());
 
        // first, accept/reject changes within each individual paragraph (do not consider end-of-par)
        for (pit_type pit = begPit; pit <= endPit; ++pit) {
@@ -1389,8 +1389,8 @@ void Text::acceptOrRejectChanges(Cursor & cur, ChangeOp op)
                if (pit == endPit && endPos == 0)
                        break; // last iteration anyway
 
-               pos_type left  = (pit == begPit ? begPos : 0);
-               pos_type right = (pit == endPit ? endPos : parSize);
+               pos_type const left  = (pit == begPit ? begPos : 0);
+               pos_type const right = (pit == endPit ? endPos : parSize);
 
                if (left == right)
                        // there is no change here
@@ -1733,7 +1733,8 @@ bool Text::backspace(Cursor & cur)
                Cursor prev_cur = cur;
                --prev_cur.pit();
 
-               if (!prev_cur.paragraph().isMergedOnEndOfParDeletion(cur.buffer()->params().track_changes)) {
+               if (cur.paragraph().size() > 0
+                   && !prev_cur.paragraph().isMergedOnEndOfParDeletion(cur.buffer()->params().track_changes)) {
                        cur.recordUndo(prev_cur.pit(), prev_cur.pit());
                        prev_cur.paragraph().setChange(prev_cur.lastpos(), Change(Change::DELETED));
                        setCursorIntern(cur, prev_cur.pit(), prev_cur.lastpos());
@@ -1767,7 +1768,7 @@ bool Text::backspace(Cursor & cur)
        needsUpdate |= handleBibitems(cur);
 
        // A singlePar update is not enough in this case.
-//             cur.screenUpdateFlags(Update::Force);
+       // cur.screenUpdateFlags(Update::Force);
        cur.top().setPitPos(cur.pit(), cur.pos());
 
        return needsUpdate;
@@ -1812,6 +1813,10 @@ bool Text::dissolveInset(Cursor & cur)
                // but we'll try the cheaper solution here.
                cur.buffer()->clearReferenceCache();
 
+               if (!lyxrc.ct_markup_copied)
+                       // Do not revive deleted text
+                       lyx::acceptChanges(plist, b.params());
+
                // ERT paragraphs have the Language latex_language.
                // This is invalid outside of ERT, so we need to
                // change it to the buffer language.
@@ -1820,14 +1825,16 @@ bool Text::dissolveInset(Cursor & cur)
                for (; it != it_end; ++it)
                        it->changeLanguage(b.params(), latex_language, b.language());
 
-               /* the inset is the only thing in paragraph, then the layout
-                * of the first paragraph of inset should be remembered.
+               /* If the inset is the only thing in paragraph and the layout
+                * is not plain, then the layout of the first paragraph of
+                * inset should be remembered.
                 * FIXME: this does not work as expected when change tracking
                 *   is on However, we do not really know what to do in this
                 *   case.
                 */
+               DocumentClass const & tclass = cur.buffer()->params().documentClass();
                if (inset_it.lastpos() == 1
-                   && inset_it.nextInset() && !inset_it.nextInset()->forcePlainLayout())
+                   && plist[0].layout().name() != tclass.plainLayoutName())
                        cur.paragraph().makeSameLayout(plist[0]);
 
                pasteParagraphList(cur, plist, b.params().documentClassPtr(),