X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FBufferList.cpp;h=e19c8aa63d3f86523e7da5f4609fef018c28cb82;hb=3dfe917a4ed504de29ac18028936d02f856c92b1;hp=0daca0929f6e53bb6b80b81a391fec6583c09778;hpb=0c9da47505379b979994bb8cf01feb2653774d14;p=lyx.git diff --git a/src/BufferList.cpp b/src/BufferList.cpp index 0daca0929f..e19c8aa63d 100644 --- a/src/BufferList.cpp +++ b/src/BufferList.cpp @@ -254,17 +254,33 @@ struct equivalent_to : public binary_function } -Buffer * BufferList::getBuffer(support::FileName const & fname) const +Buffer * BufferList::getBuffer(support::FileName const & fname, bool internal) const { // 1) cheap test, using string comparison of file names BufferStorage::const_iterator it = find_if(bstore.begin(), bstore.end(), lyx::bind(equal_to(), lyx::bind(&Buffer::fileName, _1), fname)); if (it != bstore.end()) - return *it; + return *it; // 2) possibly expensive test, using equivalence test of file names it = find_if(bstore.begin(), bstore.end(), lyx::bind(equivalent_to(), lyx::bind(&Buffer::fileName, _1), fname)); - return it != bstore.end() ? (*it) : 0; + if (it != bstore.end()) + return *it; + + if (internal) { + // 1) cheap test, using string comparison of file names + BufferStorage::const_iterator it = find_if(binternal.begin(), binternal.end(), + lyx::bind(equal_to(), lyx::bind(&Buffer::fileName, _1), fname)); + if (it != binternal.end()) + return *it; + // 2) possibly expensive test, using equivalence test of file names + it = find_if(binternal.begin(), binternal.end(), + lyx::bind(equivalent_to(), lyx::bind(&Buffer::fileName, _1), fname)); + if (it != binternal.end()) + return *it; + } + + return 0; }