Do not check for duplicates when pasting a label into a non-outputting inset.

Issue mentioned at #10333
This commit is contained in:
Juergen Spitzmueller 2019-01-25 14:40:30 +01:00
parent 63807af2ca
commit a936bc2df5
3 changed files with 19 additions and 5 deletions

View 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");

View 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);
}

View 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);