diff --git a/src/BiblioInfo.cpp b/src/BiblioInfo.cpp index 9458984f96..15e5772068 100644 --- a/src/BiblioInfo.cpp +++ b/src/BiblioInfo.cpp @@ -1393,32 +1393,28 @@ docstring const BiblioInfo::getInfo(docstring const & key, } -docstring const BiblioInfo::getLabel(vector keys, +docstring const BiblioInfo::getLabel(vector const & keys, Buffer const & buf, string const & style, CiteItem const & ci) const { size_t max_size = ci.max_size; // shorter makes no sense LASSERT(max_size >= 16, max_size = 16); - // we can't display more than 10 of these, anyway - // but since we truncate in the middle, - // we need to split into two halfs. - bool const too_many_keys = keys.size() > 10; - vector lkeys; - if (too_many_keys) { - lkeys.insert(lkeys.end(), keys.end() - 5, keys.end()); - keys.resize(5); - keys.insert(keys.end(), lkeys.begin(), lkeys.end()); - } - CiteEngineType const engine_type = buf.params().citeEngineType(); DocumentClass const & dc = buf.params().documentClass(); docstring const & format = from_utf8(dc.getCiteFormat(engine_type, style, false, "cite")); docstring ret = format; - vector::const_iterator key = keys.begin(); - vector::const_iterator ken = keys.end(); + auto key = keys.begin(); + auto const ken = keys.end(); vector handled_keys; for (int i = 0; key != ken; ++key, ++i) { + // we can't display more than 10 keys anyway, so keep 5 from + // the start and 5 from the end. + if (i == 5 && keys.size() > 10) { + i = keys.size() - 5; + key = ken - 5; + } + handled_keys.push_back(*key); int n = 0; for (auto const & k : handled_keys) { diff --git a/src/BiblioInfo.h b/src/BiblioInfo.h index 7b7a80e058..c42d3e0318 100644 --- a/src/BiblioInfo.h +++ b/src/BiblioInfo.h @@ -241,7 +241,7 @@ public: bool const for_xhtml = false) const; /// \return formatted BibTeX data for citation labels. /// Citation labels can have more than one key. - docstring const getLabel(std::vector keys, Buffer const & buf, + docstring const getLabel(std::vector const & keys, Buffer const & buf, std::string const & style, CiteItem const & ci) const; /// Is this a reference from a bibtex database /// or from a bibliography environment?