From d5e8b614f7f391eabe42988f72c992004eeb0556 Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Mon, 31 Dec 2018 18:30:20 +0100 Subject: [PATCH] Add inactive labels to the toc It makes sense to navigate to them. They are marked as inactive with the cross. --- src/insets/InsetLabel.cpp | 17 ++++++++++------- src/insets/InsetRef.cpp | 4 +++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/insets/InsetLabel.cpp b/src/insets/InsetLabel.cpp index c3bf43f117..cb419f397d 100644 --- a/src/insets/InsetLabel.cpp +++ b/src/insets/InsetLabel.cpp @@ -186,17 +186,20 @@ void InsetLabel::updateBuffer(ParIterator const & par, UpdateType utype) void InsetLabel::addToToc(DocIterator const & cpit, bool output_active, - UpdateType, TocBackend & backend) const + UpdateType, TocBackend & backend) const { 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 = backend.toc("label"); - if (buffer().insetLabel(label, true) != this) { - toc->push_back(TocItem(cpit, 0, screen_label_, output_active)); - } else { - 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, + // assign the (BROKEN) refs to the first inactive one. + if (buffer().insetLabel(label, true) == this || !buffer().activeLabel(label)) { for (auto const & p : buffer().references(label)) { DocIterator const ref_pit(p.second); if (p.first->lyxCode() == MATH_REF_CODE) diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp index 9f23ca4684..75fce643bb 100644 --- a/src/insets/InsetRef.cpp +++ b/src/insets/InsetRef.cpp @@ -423,9 +423,11 @@ void InsetRef::addToToc(DocIterator const & cpit, bool output_active, UpdateType, TocBackend & backend) const { 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(). return; + } // It seems that this reference does not point to any valid label. -- 2.39.5