]> git.lyx.org Git - lyx.git/blobdiff - src/CutAndPaste.C
do not create invalid .lyx files when importing \i{}, \j{}, \l{} or \L{}.
[lyx.git] / src / CutAndPaste.C
index 0272f978b5319a1af72afb0174c354d8b994e822..d82aab8faa82d0c5597035705fc66eefc5568ac4 100644 (file)
@@ -210,8 +210,8 @@ pasteSelectionHelper(LCursor & cur, ParagraphList const & parlist,
        ParIterator fend = par_iterator_end(in);
 
        for (; fpit != fend; ++fpit) {
-               InsetList::iterator lit = fpit->insetlist.begin();
-               InsetList::iterator eit = fpit->insetlist.end();
+               InsetList::const_iterator lit = fpit->insetlist.begin();
+               InsetList::const_iterator eit = fpit->insetlist.end();
 
                for (; lit != eit; ++lit) {
                        switch (lit->inset->lyxCode()) {
@@ -297,18 +297,11 @@ PitPosPair eraseSelectionHelper(BufferParams const & params,
                pos_type const left  = (pit == startpit ? startpos : 0);
                pos_type const right = (pit == endpit ? endpos : pars[pit].size() + 1);
 
+               bool const merge = pars[pit].isMergedOnEndOfParDeletion(params.trackChanges);
+
                // Logically erase only, including the end-of-paragraph character
                pars[pit].eraseChars(left, right, params.trackChanges);
 
-               // A paragraph break has to be physically removed by merging only
-               // if either (1) change tracking is off, or (2) the imaginary 
-               // end-of-paragraph character is marked as inserted even after
-               // the erase operation (please see Paragraph::Pimpl::eraseChar(...)
-               // for details on end-of-par handling)
-
-               bool const merge = !params.trackChanges ||
-                                  pars[pit].isInserted(pars[pit].size());
-
                // Separate handling of paragraph break:
                if (merge && pit != endpit &&
                    (pit + 1 != endpit || pars[pit].hasSameLayout(pars[pit + 1]))) {
@@ -656,7 +649,7 @@ void pasteSelection(LCursor & cur, ErrorList & errorList, size_t sel_index)
 
 
 // simple replacing. The font of the first selected character is used
-void replaceSelectionWithString(LCursor & cur, string const & str, bool backwards)
+void replaceSelectionWithString(LCursor & cur, docstring const & str, bool backwards)
 {
        recordUndo(cur);
        DocIterator selbeg = cur.selectionBegin();
@@ -668,10 +661,10 @@ void replaceSelectionWithString(LCursor & cur, string const & str, bool backward
        // Insert the new string
        pos_type pos = cur.selEnd().pos();
        Paragraph & par = cur.selEnd().paragraph();
-       string::const_iterator cit = str.begin();
-       string::const_iterator end = str.end();
+       docstring::const_iterator cit = str.begin();
+       docstring::const_iterator end = str.end();
        for (; cit != end; ++cit, ++pos)
-               par.insertChar(pos, (*cit), font, cur.buffer().params().trackChanges);
+               par.insertChar(pos, *cit, font, cur.buffer().params().trackChanges);
 
        // Cut the selection
        cutSelection(cur, true, false);