Index: clang-tools-extra/clangd/index/dex/Dex.cpp =================================================================== --- clang-tools-extra/clangd/index/dex/Dex.cpp +++ clang-tools-extra/clangd/index/dex/Dex.cpp @@ -144,8 +144,10 @@ if (It != InvertedIndex.end()) TrigramIterators.push_back(create(It->second)); } - if (!TrigramIterators.empty()) + if (TrigramIterators.size() > 1) TopLevelChildren.push_back(createAnd(move(TrigramIterators))); + else if (TrigramIterators.size() == 1) + TopLevelChildren.push_back(move(TrigramIterators.front())); // Generate scope tokens for search query. std::vector> ScopeIterators; @@ -155,8 +157,10 @@ ScopeIterators.push_back(create(It->second)); } // Add OR iterator for scopes if there are any Scope Iterators. - if (!ScopeIterators.empty()) + if (ScopeIterators.size() > 1) TopLevelChildren.push_back(createOr(move(ScopeIterators))); + else if (ScopeIterators.size() == 1) + TopLevelChildren.push_back(move(ScopeIterators.front())); // Add proximity paths boosting. auto BoostingIterators = createFileProximityIterators(