[clangd] Igore cases in index fuzzy find.

llvm-svn: 321157
This commit is contained in:
Eric Liu 2017-12-20 09:29:54 +00:00
parent 700a28a764
commit 125cda7d3b
2 changed files with 11 additions and 1 deletions

View File

@ -49,7 +49,7 @@ bool MemIndex::fuzzyFind(const Context &Ctx, const FuzzyFindRequest &Req,
continue;
// FIXME(ioeric): use fuzzy matcher.
if (StringRef(StringRef(Sym->Name).lower()).contains(Req.Query)) {
if (StringRef(Sym->Name).find_lower(Req.Query) != StringRef::npos) {
if (++Matched > Req.MaxCandidateCount)
return false;
Callback(*Sym);

View File

@ -178,6 +178,16 @@ TEST(MemIndexTest, NoMatchNestedScopes) {
EXPECT_THAT(match(I, Req), UnorderedElementsAre("a::xyz"));
}
TEST(MemIndexTest, IgnoreCases) {
MemIndex I;
I.build(generateSymbols({"ns::ABC", "ns::abc"}));
FuzzyFindRequest Req;
Req.Query = "AB";
Req.Scopes = {"ns"};
auto Matches = match(I, Req);
EXPECT_THAT(match(I, Req), UnorderedElementsAre("ns::ABC", "ns::abc"));
}
} // namespace
} // namespace clangd
} // namespace clang