]> git.lyx.org Git - lyx.git/commitdiff
Fix assertion when pasting paragraph with insets in lyxrc.ct_markup_copied
authorJuergen Spitzmueller <spitz@lyx.org>
Sat, 6 Apr 2024 07:47:22 +0000 (09:47 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Sat, 6 Apr 2024 07:47:22 +0000 (09:47 +0200)
This has to be done after the inset buffers have been initialized.

src/CutAndPaste.cpp

index 7fd76f98bcbabe0dc622ba95470f47feb7735875..226b48e250f4b1a593957e66614945463303becd 100644 (file)
@@ -292,26 +292,6 @@ pasteSelectionHelper(DocIterator const & cur, ParagraphList const & parlist,
                                if (!target_inset->insetAllowed(inset->lyxCode()))
                                        tmpbuf->eraseChar(i--, false);
                }
-
-               if (lyxrc.ct_markup_copied) {
-                       // Only remove deleted text and change
-                       // the rest to inserted if ct is active,
-                       // otherwise leave markup as is
-                       if (buffer.params().track_changes) {
-                               if (tmpbuf->size() > 0) {
-                                   if (!isFullyDeleted(insertion))
-                                           tmpbuf->acceptChanges(0, tmpbuf->size());
-                                   else
-                                           tmpbuf->rejectChanges(0, tmpbuf->size());
-                               }
-                               tmpbuf->setChange(Change(Change::INSERTED));
-                       }
-               } else
-                       // Resolve all markup to inserted or unchanged
-                       // Deleted text has already been removed on copy
-                       // (copySelectionHelper)
-                       tmpbuf->setChange(Change(buffer.params().track_changes ?
-                                                Change::INSERTED : Change::UNCHANGED));
        }
 
        bool const target_empty = pars[pit].empty();
@@ -495,6 +475,29 @@ pasteSelectionHelper(DocIterator const & cur, ParagraphList const & parlist,
        }
        insertion.swap(in.paragraphs());
 
+       tmpbuf = insertion.begin();
+       for (; tmpbuf != insertion.end(); ++tmpbuf) {
+               if (lyxrc.ct_markup_copied) {
+                       // Only remove deleted text and change
+                       // the rest to inserted if ct is active,
+                       // otherwise leave markup as is
+                       if (buffer.params().track_changes) {
+                               if (tmpbuf->size() > 0) {
+                                       if (!isFullyDeleted(insertion))
+                                               tmpbuf->acceptChanges(0, tmpbuf->size());
+                                       else
+                                               tmpbuf->rejectChanges(0, tmpbuf->size());
+                               }
+                               tmpbuf->setChange(Change(Change::INSERTED));
+                       }
+               } else
+                       // Resolve all markup to inserted or unchanged
+                       // Deleted text has already been removed on copy
+                       // (copySelectionHelper)
+                       tmpbuf->setChange(Change(buffer.params().track_changes ?
+                                                Change::INSERTED : Change::UNCHANGED));
+       }
+
        // Split the paragraph for inserting the buf if necessary.
        if (!target_empty)
                breakParagraphConservative(buffer.params(), pars, pit, pos);