]> git.lyx.org Git - features.git/commitdiff
Do not check for duplicates when pasting a label into a non-outputting inset.
authorJuergen Spitzmueller <spitz@lyx.org>
Fri, 25 Jan 2019 13:40:30 +0000 (14:40 +0100)
committerJuergen Spitzmueller <spitz@lyx.org>
Fri, 25 Jan 2019 13:40:30 +0000 (14:40 +0100)
Issue mentioned at #10333

src/CutAndPaste.cpp
src/insets/InsetLabel.cpp
src/insets/InsetLabel.h

index 0f269b27e49e7423238fed5d614f4cb6f62e08d6..c71697ffda99b8892b57de705c5c0038541da0fc 100644 (file)
@@ -125,6 +125,19 @@ pasteSelectionHelper(DocIterator const & cur, ParagraphList const & parlist,
        if (parlist.empty())
                return PasteReturnValue(pit, pos, need_update);
 
+       // Check whether we paste into an inset that does not
+       // produce output (needed for label duplicate check)
+       bool in_active_inset = cur.paragraph().inInset().producesOutput();
+       if (in_active_inset) {
+               for (size_type sl = 0 ; sl < cur.depth() ; ++sl) {
+                       Paragraph const & outer_par = cur[sl].paragraph();
+                       if (!outer_par.inInset().producesOutput()) {
+                               in_active_inset = false;
+                               break;
+                       }
+               }
+       }
+
        InsetText * target_inset = cur.inset().asInsetText();
        if (!target_inset) {
                InsetTabular * it = cur.inset().asInsetTabular();
@@ -305,7 +318,7 @@ pasteSelectionHelper(DocIterator const & cur, ParagraphList const & parlist,
                                        continue;
                                InsetLabel * lab = labels[i];
                                docstring const oldname = lab->getParam("name");
-                               lab->updateLabel(oldname);
+                               lab->updateLabel(oldname, in_active_inset);
                                // We need to update the buffer reference cache.
                                need_update = true;
                                docstring const newname = lab->getParam("name");
@@ -336,7 +349,7 @@ pasteSelectionHelper(DocIterator const & cur, ParagraphList const & parlist,
                        // check for duplicates
                        InsetLabel & lab = static_cast<InsetLabel &>(*it);
                        docstring const oldname = lab.getParam("name");
-                       lab.updateLabel(oldname);
+                       lab.updateLabel(oldname, in_active_inset);
                        // We need to update the buffer reference cache.
                        need_update = true;
                        docstring const newname = lab.getParam("name");
index 768d8293dce23fe625d354419ac5f0b75899870a..e325f1ea94c5431b6c019d9c9719b39e4ad0494f 100644 (file)
@@ -82,10 +82,11 @@ void InsetLabel::uniqueLabel(docstring & label) const
 }
 
 
-void InsetLabel::updateLabel(docstring const & new_label)
+void InsetLabel::updateLabel(docstring const & new_label, bool const active)
 {
        docstring label = new_label;
-       uniqueLabel(label);
+       if (active)
+               uniqueLabel(label);
        setParam("name", label);
 }
 
index 22131ab4a157bc6a11d44e6773a12c873de2fb43..92c3380f7077ca066a79b6a3940e0c0a1e5475e0 100644 (file)
@@ -32,7 +32,7 @@ public:
        ///
        docstring const & prettyCounter() const { return pretty_counter_; }
        /// Updates only the label string, doesn't handle undo nor references.
-       void updateLabel(docstring const & new_label);
+       void updateLabel(docstring const & new_label, bool const active = true);
        /// Updates the label and the references to it.
        /// Will also handle undo/redo if \p cursor is passed.
        void updateLabelAndRefs(docstring const & new_label, Cursor * cursor = 0);