]> git.lyx.org Git - lyx.git/blobdiff - src/CutAndPaste.cpp
VCS: Handle one boundary condition.
[lyx.git] / src / CutAndPaste.cpp
index eb70bb8e1e89005bfae2a7831e871562fabef7c5..f13664b35df76db5ec2e41aa51f12e5e3c289beb 100644 (file)
@@ -124,6 +124,7 @@ pasteSelectionHelper(Cursor & cur, ParagraphList const & parlist,
                                        breakParagraphConservative(
                                                        buffer.params(),
                                                        insertion, i, j);
+                                       break;
                                }
                        }
                }
@@ -153,8 +154,9 @@ pasteSelectionHelper(Cursor & cur, ParagraphList const & parlist,
                }
        }
 
+       InsetText in(buffer);
        // Make sure there is no class difference.
-       InsetText in;
+       in.paragraphs().clear();
        // This works without copying any paragraph data because we have
        // a specialized swap method for ParagraphList. This is important
        // since we store pointers to insets at some places and we don't
@@ -284,6 +286,9 @@ pasteSelectionHelper(Cursor & cur, ParagraphList const & parlist,
                // merge the first par of the insertion with the current par
                mergeParagraph(buffer.params(), pars, pit);
        }
+       //FIXME: We should call setBuffer() on each inserted paragraph.
+       // instead, we call setBuffer() for the main inset at the beginning
+       // of updateLabels()
 
        pit_type last_paste = pit + insertion.size() - 1;
 
@@ -366,9 +371,11 @@ void putClipboard(ParagraphList const & paragraphs,
        // a DocumentClass, via new, that is never deleted. If we were to go to
        // some kind of garbage collection there, or a shared_ptr, then this
        // would not be needed.
-       static Buffer * buffer = theBufferList().newBuffer("");
+       static Buffer * buffer = theBufferList().newBuffer(
+               FileName::tempName().absFilename() + "_clipboard.internal");
        buffer->setUnnamed(true);
        buffer->paragraphs() = paragraphs;
+       buffer->inset().setBuffer(*buffer);
        buffer->params().setDocumentClass(docclass);
        ostringstream lyx;
        if (buffer->write(lyx))
@@ -756,7 +763,7 @@ void saveSelection(Cursor & cur)
        if (cur.selection() 
            && cur.selBegin() == cur.bv().cursor().selBegin()
            && cur.selEnd() == cur.bv().cursor().selEnd()) {
-               LYXERR(Debug::ACTION, "'" << cur.selectionAsString(true) << "'");
+               LYXERR(Debug::SELECTION, "saveSelection: '" << cur.selectionAsString(true) << "'");
                copySelectionToStack(cur, selectionBuffer);
        }
 }