Index: clang-tools-extra/clangd/index/dex/Iterator.cpp =================================================================== --- clang-tools-extra/clangd/index/dex/Iterator.cpp +++ clang-tools-extra/clangd/index/dex/Iterator.cpp @@ -38,6 +38,8 @@ /// or higher than the given one. void advanceTo(DocID ID) override { assert(!reachedEnd() && "DOCUMENT iterator can't advance() at the end."); + if (peek() >= ID) + return; Index = std::lower_bound(Index, std::end(Documents), ID); }