mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 03:11:59 +00:00
Do not check for duplicates when pasting a label into a non-outputting inset.
Issue mentioned at #10333
This commit is contained in:
parent
63807af2ca
commit
a936bc2df5
@ -125,6 +125,19 @@ pasteSelectionHelper(DocIterator const & cur, ParagraphList const & parlist,
|
|||||||
if (parlist.empty())
|
if (parlist.empty())
|
||||||
return PasteReturnValue(pit, pos, need_update);
|
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();
|
InsetText * target_inset = cur.inset().asInsetText();
|
||||||
if (!target_inset) {
|
if (!target_inset) {
|
||||||
InsetTabular * it = cur.inset().asInsetTabular();
|
InsetTabular * it = cur.inset().asInsetTabular();
|
||||||
@ -305,7 +318,7 @@ pasteSelectionHelper(DocIterator const & cur, ParagraphList const & parlist,
|
|||||||
continue;
|
continue;
|
||||||
InsetLabel * lab = labels[i];
|
InsetLabel * lab = labels[i];
|
||||||
docstring const oldname = lab->getParam("name");
|
docstring const oldname = lab->getParam("name");
|
||||||
lab->updateLabel(oldname);
|
lab->updateLabel(oldname, in_active_inset);
|
||||||
// We need to update the buffer reference cache.
|
// We need to update the buffer reference cache.
|
||||||
need_update = true;
|
need_update = true;
|
||||||
docstring const newname = lab->getParam("name");
|
docstring const newname = lab->getParam("name");
|
||||||
@ -336,7 +349,7 @@ pasteSelectionHelper(DocIterator const & cur, ParagraphList const & parlist,
|
|||||||
// check for duplicates
|
// check for duplicates
|
||||||
InsetLabel & lab = static_cast<InsetLabel &>(*it);
|
InsetLabel & lab = static_cast<InsetLabel &>(*it);
|
||||||
docstring const oldname = lab.getParam("name");
|
docstring const oldname = lab.getParam("name");
|
||||||
lab.updateLabel(oldname);
|
lab.updateLabel(oldname, in_active_inset);
|
||||||
// We need to update the buffer reference cache.
|
// We need to update the buffer reference cache.
|
||||||
need_update = true;
|
need_update = true;
|
||||||
docstring const newname = lab.getParam("name");
|
docstring const newname = lab.getParam("name");
|
||||||
|
@ -82,9 +82,10 @@ 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;
|
docstring label = new_label;
|
||||||
|
if (active)
|
||||||
uniqueLabel(label);
|
uniqueLabel(label);
|
||||||
setParam("name", label);
|
setParam("name", label);
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ public:
|
|||||||
///
|
///
|
||||||
docstring const & prettyCounter() const { return pretty_counter_; }
|
docstring const & prettyCounter() const { return pretty_counter_; }
|
||||||
/// Updates only the label string, doesn't handle undo nor references.
|
/// 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.
|
/// Updates the label and the references to it.
|
||||||
/// Will also handle undo/redo if \p cursor is passed.
|
/// Will also handle undo/redo if \p cursor is passed.
|
||||||
void updateLabelAndRefs(docstring const & new_label, Cursor * cursor = 0);
|
void updateLabelAndRefs(docstring const & new_label, Cursor * cursor = 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user