Add inactive labels to the toc

It makes sense to navigate to them.

They are marked as inactive with the cross.
This commit is contained in:
Juergen Spitzmueller 2018-12-31 18:30:20 +01:00
parent 54366c38ef
commit e61c60fae8
2 changed files with 13 additions and 8 deletions

View File

@ -186,17 +186,20 @@ void InsetLabel::updateBuffer(ParIterator const & par, UpdateType utype)
void InsetLabel::addToToc(DocIterator const & cpit, bool output_active, void InsetLabel::addToToc(DocIterator const & cpit, bool output_active,
UpdateType, TocBackend & backend) const UpdateType, TocBackend & backend) const
{ {
docstring const & label = getParam("name"); docstring const & label = getParam("name");
if (!buffer().activeLabel(label))
return;
// inactive labels get a cross mark
if (buffer().insetLabel(label, true) != this)
output_active = false;
// We put both active and inactive labels to the outliner
shared_ptr<Toc> toc = backend.toc("label"); shared_ptr<Toc> toc = backend.toc("label");
if (buffer().insetLabel(label, true) != this) { toc->push_back(TocItem(cpit, 0, screen_label_, output_active));
toc->push_back(TocItem(cpit, 0, screen_label_, output_active)); // The refs get assigned only to the active label. If no active one exists,
} else { // assign the (BROKEN) refs to the first inactive one.
toc->push_back(TocItem(cpit, 0, screen_label_, output_active)); if (buffer().insetLabel(label, true) == this || !buffer().activeLabel(label)) {
for (auto const & p : buffer().references(label)) { for (auto const & p : buffer().references(label)) {
DocIterator const ref_pit(p.second); DocIterator const ref_pit(p.second);
if (p.first->lyxCode() == MATH_REF_CODE) if (p.first->lyxCode() == MATH_REF_CODE)

View File

@ -423,9 +423,11 @@ void InsetRef::addToToc(DocIterator const & cpit, bool output_active,
UpdateType, TocBackend & backend) const UpdateType, TocBackend & backend) const
{ {
docstring const & label = getParam("reference"); docstring const & label = getParam("reference");
if (buffer().activeLabel(label)) if (buffer().insetLabel(label)) {
broken_ = !buffer().activeLabel(label);
// This InsetRef has already been taken care of in InsetLabel::addToToc(). // This InsetRef has already been taken care of in InsetLabel::addToToc().
return; return;
}
// It seems that this reference does not point to any valid label. // It seems that this reference does not point to any valid label.