]> git.lyx.org Git - features.git/commitdiff
Add inactive labels to the toc
authorJuergen Spitzmueller <spitz@lyx.org>
Mon, 31 Dec 2018 17:30:20 +0000 (18:30 +0100)
committerJuergen Spitzmueller <spitz@lyx.org>
Mon, 31 Dec 2018 17:30:20 +0000 (18:30 +0100)
It makes sense to navigate to them.

They are marked as inactive with the cross.

src/insets/InsetLabel.cpp
src/insets/InsetRef.cpp

index c3bf43f1176fa3f24ac4e35ff8af6236212d3f07..cb419f397d88fa2f3f56e86b982b00f0bfe348a4 100644 (file)
@@ -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> 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)
index 9f23ca46848b6e178ea0d3843b3666a903292064..75fce643bbb54c02fc5da5560cecc00052b140a8 100644 (file)
@@ -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.