]> git.lyx.org Git - lyx.git/blobdiff - src/BiblioInfo.cpp
Avoid endless loop when the window is too narrow
[lyx.git] / src / BiblioInfo.cpp
index 86ae70b7db95464ddb4f633ece5a72d39238e0c8..f2bf332a2655204b8dbdce3b630bbc4c5fbd0c20 100644 (file)
@@ -466,7 +466,15 @@ docstring parseOptions(docstring const & format, string & optkey,
 
 } // anon namespace
 
-
+/* FIXME
+Bug #9131 revealed an oddity in how we are generating citation information
+when more than one key is given. We end up building a longer and longer format 
+string as we go, which we then have to re-parse, over and over and over again,
+rather than generating the information for the individual keys and then putting
+all of that together. We do that to deal with the way separators work, from what
+I can tell, but it still feels like a hack. Fixing this would require quite a
+bit of work, however.
+*/
 docstring BibTeXInfo::expandFormat(docstring const & format,
                BibTeXInfo const * const xref, int & counter, Buffer const & buf,
                docstring before, docstring after, docstring dialog, bool next) const
@@ -748,8 +756,7 @@ docstring BibTeXInfo::getValueForKey(string const & oldkey, Buffer const & buf,
                ret = html::cleanAttr(ret);
 
        // make sure it is not too big
-       if (ret.size() > maxsize)
-               ret = ret.substr(0, maxsize - 3) + from_ascii("...");
+       support::truncateWithEllipsis(ret, maxsize);
        return ret;
 }
 
@@ -920,21 +927,18 @@ docstring const BiblioInfo::getLabel(vector<docstring> keys,
                        before, after, dialog, key + 1 != ken);
        }
 
-       if (ret.size() > max_size) {
-               ret.resize(max_size - 3);
-               ret += "...";
-       } else if (too_many_keys) {
-               if (ret.size() > max_size - 3)
-                       ret.resize(max_size - 3);
-               ret += "...";
-       }
+       if (too_many_keys)
+               ret.push_back(0x2026);//HORIZONTAL ELLIPSIS
+       support::truncateWithEllipsis(ret, max_size);
        return ret;
 }
 
 
 bool BiblioInfo::isBibtex(docstring const & key) const
 {
-       BiblioInfo::const_iterator it = find(key);
+       docstring key1;
+       split(key, key1, ',');
+       BiblioInfo::const_iterator it = find(key1);
        if (it == end())
                return false;
        return it->second.isBibTeX();
@@ -995,9 +999,9 @@ void BiblioInfo::collectCitedEntries(Buffer const & buf)
        // FIXME We may want to collect these differently, in the first case,
        // so that we might have them in order of appearance.
        set<docstring> citekeys;
-       Toc const & toc = buf.tocBackend().toc("citation");
-       Toc::const_iterator it = toc.begin();
-       Toc::const_iterator const en = toc.end();
+       shared_ptr<Toc const> toc = buf.tocBackend().toc("citation");
+       Toc::const_iterator it = toc->begin();
+       Toc::const_iterator const en = toc->end();
        for (; it != en; ++it) {
                if (it->str().empty())
                        continue;