]> git.lyx.org Git - features.git/commitdiff
Put use_formatted_reference code in addToToc instead of updateBuffer
authorAlexander Dunlap <alexander.dunlap@gmail.com>
Sun, 30 Jul 2023 17:32:48 +0000 (13:32 -0400)
committerRichard Kimberly Heck <rikiheck@lyx.org>
Fri, 25 Aug 2023 01:24:35 +0000 (21:24 -0400)
to handle forward references.

src/insets/InsetRef.cpp

index fcd28d234659c430a9c54676cf0d0dd420505d51..52e111828672008692b8f187936a488643df45eb 100644 (file)
@@ -537,11 +537,10 @@ void InsetRef::updateBuffer(ParIterator const & it, UpdateType, bool const /*del
        } else
                tooltip_ = from_ascii("");
 
-       if (use_formatted_ref && cmd != "pageref" && cmd != "vpageref"
-                       && cmd != "vref" && cmd != "labelonly")
-               screen_label_ = displayString(ref, cmd);
-       else
-               screen_label_ = label;
+       screen_label_ = label;
+       // If use_formatted_ref is active, this will be overwritten in addToToc.
+       // (We can't do it now because it might be a forward-reference
+       // and so the reference might not be in the label cache yet.
        broken_ = false;
        setBroken(broken_);
 }
@@ -566,9 +565,14 @@ void InsetRef::addToToc(DocIterator const & cpit, bool output_active,
                        toc2->push_back(TocItem(cpit, 0, screenLabel(), output_active));
                }
                // This InsetRef has already been taken care of in InsetLabel::addToToc().
+               bool const use_formatted_ref = buffer().params().use_formatted_ref;
+               string const & cmd = getCmdName();
+               docstring const & ref = getParam("reference");
+               if (use_formatted_ref && cmd != "pageref" && cmd != "vpageref"
+                           && cmd != "vref" && cmd != "labelonly")
+                       screen_label_ = displayString(ref, cmd);
                return;
        }
-
        // It seems that this reference does not point to any valid label.
        broken_ = true;
        setBroken(broken_);