Fix display of counters for included listings.

This commit is contained in:
Richard Kimberly Heck 2024-02-09 19:53:55 -05:00
parent fe99f7b01e
commit 91bd457a67
2 changed files with 15 additions and 8 deletions

View File

@ -79,6 +79,7 @@ End
Counter listing
GuiName Listing
PrettyFormat "Listing ##"
End
Counter equation

View 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));
}
}