]> git.lyx.org Git - features.git/commitdiff
Fix display of counters for included listings.
authorRichard Kimberly Heck <rikiheck@lyx.org>
Sat, 10 Feb 2024 00:53:55 +0000 (19:53 -0500)
committerRichard Kimberly Heck <rikiheck@lyx.org>
Sat, 10 Feb 2024 00:54:56 +0000 (19:54 -0500)
lib/layouts/stdcounters.inc
src/insets/InsetInclude.cpp

index dbebe25b0359f6fd7587446846471c1ee62022d4..ee143f6b0f6a52f30d10328478b693ea2d917112 100644 (file)
@@ -79,6 +79,7 @@ End
 
 Counter listing
        GuiName Listing
+       PrettyFormat "Listing ##"
 End
 
 Counter equation
index 916196211ad0a591d84af8bff0ad2be7f2e4d18c..92ec17169c724cea454c27d4f640a67c6742bb50 100644 (file)
@@ -1444,22 +1444,28 @@ void InsetInclude::updateBuffer(ParIterator const & it, UpdateType utype, bool c
        if (!isListings(params()))
                return;
 
+       Buffer const & master = *buffer().masterBuffer();
+       listings_label_ = master.B_("Program Listing");
+       Counters & counters = master.params().documentClass().counters();
+       docstring const cnt = from_ascii("listing");
+       bool const hasCounter = counters.hasCounter(cnt);
+       if (hasCounter) {
+               counters.saveLastCounter();
+               counters.step(cnt, utype);
+               listings_label_ += " " + convert<docstring>(counters.value(cnt));
+       }
+
        if (label_)
                label_->updateBuffer(it, utype, deleted);
 
+       if (hasCounter)
+               counters.restoreLastCounter();
+
        InsetListingsParams const par(to_utf8(params()["lstparams"]));
        if (par.getParamValue("caption").empty()) {
                listings_label_ = buffer().B_("Program Listing");
                return;
        }
-       Buffer const & master = *buffer().masterBuffer();
-       Counters & counters = master.params().documentClass().counters();
-       docstring const cnt = from_ascii("listing");
-       listings_label_ = master.B_("Program Listing");
-       if (counters.hasCounter(cnt)) {
-               counters.step(cnt, utype);
-               listings_label_ += " " + convert<docstring>(counters.value(cnt));
-       }
 }