Index: clangd/CodeComplete.cpp =================================================================== --- clangd/CodeComplete.cpp +++ clangd/CodeComplete.cpp @@ -249,7 +249,10 @@ I.kind = toCompletionItemKind(SemaResult->Kind, SemaResult->Declaration); getLabelAndInsertText(*SemaCCS, &I.label, &I.insertText, Opts.EnableSnippets); - I.filterText = getFilterText(*SemaCCS); + if (SemaResult->Declaration) + I.filterText = SemaResult->Declaration->getDeclName().getAsString(); + else if (const char* Text = SemaCCS->getTypedText()) + I.filterText = Text; I.documentation = formatDocumentation(*SemaCCS, SemaDocComment); I.detail = getDetail(*SemaCCS); } Index: clangd/CodeCompletionStrings.h =================================================================== --- clangd/CodeCompletionStrings.h +++ clangd/CodeCompletionStrings.h @@ -65,11 +65,6 @@ /// is usually the return type of a function. std::string getDetail(const CodeCompletionString &CCS); -/// Gets the piece of text that the user is expected to type to match the -/// code-completion string, typically a keyword or the name of a declarator or -/// macro. -std::string getFilterText(const CodeCompletionString &CCS); - } // namespace clangd } // namespace clang Index: clangd/CodeCompletionStrings.cpp =================================================================== --- clangd/CodeCompletionStrings.cpp +++ clangd/CodeCompletionStrings.cpp @@ -249,18 +249,5 @@ return ""; } -std::string getFilterText(const CodeCompletionString &CCS) { - for (const auto &Chunk : CCS) { - switch (Chunk.Kind) { - case CodeCompletionString::CK_TypedText: - // There's always exactly one CK_TypedText chunk. - return Chunk.Text; - default: - break; - } - } - return ""; -} - } // namespace clangd } // namespace clang Index: clangd/index/Index.h =================================================================== --- clangd/index/Index.h +++ clangd/index/Index.h @@ -156,10 +156,6 @@ /// candidate list. For example, "Foo(X x, Y y) const" is a label for a /// function. llvm::StringRef CompletionLabel; - /// The piece of text that the user is expected to type to match the - /// code-completion string, typically a keyword or the name of a declarator or - /// macro. - llvm::StringRef CompletionFilterText; /// What to insert when completing this symbol (plain text version). llvm::StringRef CompletionPlainInsertText; /// What to insert when completing this symbol (snippet version). This is Index: clangd/index/Index.cpp =================================================================== --- clangd/index/Index.cpp +++ clangd/index/Index.cpp @@ -85,7 +85,6 @@ Intern(S.Definition.FileURI); Intern(S.CompletionLabel); - Intern(S.CompletionFilterText); Intern(S.CompletionPlainInsertText); Intern(S.CompletionSnippetInsertText); Index: clangd/index/Merge.cpp =================================================================== --- clangd/index/Merge.cpp +++ clangd/index/Merge.cpp @@ -98,8 +98,6 @@ S.References += O.References; if (S.CompletionLabel == "") S.CompletionLabel = O.CompletionLabel; - if (S.CompletionFilterText == "") - S.CompletionFilterText = O.CompletionFilterText; if (S.CompletionPlainInsertText == "") S.CompletionPlainInsertText = O.CompletionPlainInsertText; if (S.CompletionSnippetInsertText == "") Index: clangd/index/SymbolCollector.cpp =================================================================== --- clangd/index/SymbolCollector.cpp +++ clangd/index/SymbolCollector.cpp @@ -402,7 +402,6 @@ /*EnableSnippets=*/true); getLabelAndInsertText(*CCS, &IgnoredLabel, &PlainInsertText, /*EnableSnippets=*/false); - std::string FilterText = getFilterText(*CCS); std::string Documentation = formatDocumentation(*CCS, getDocComment(Ctx, SymbolCompletion, /*CommentsFromHeaders=*/true)); @@ -416,7 +415,6 @@ QName, SM, SM.getExpansionLoc(ND.getLocation()), Opts)) Include = std::move(*Header); } - S.CompletionFilterText = FilterText; S.CompletionLabel = Label; S.CompletionPlainInsertText = PlainInsertText; S.CompletionSnippetInsertText = SnippetInsertText; Index: clangd/index/SymbolYAML.cpp =================================================================== --- clangd/index/SymbolYAML.cpp +++ clangd/index/SymbolYAML.cpp @@ -111,7 +111,6 @@ IO.mapOptional("IsIndexedForCodeCompletion", Sym.IsIndexedForCodeCompletion, false); IO.mapRequired("CompletionLabel", Sym.CompletionLabel); - IO.mapRequired("CompletionFilterText", Sym.CompletionFilterText); IO.mapRequired("CompletionPlainInsertText", Sym.CompletionPlainInsertText); IO.mapOptional("CompletionSnippetInsertText", Index: unittests/clangd/CodeCompletionStringsTests.cpp =================================================================== --- unittests/clangd/CodeCompletionStringsTests.cpp +++ unittests/clangd/CodeCompletionStringsTests.cpp @@ -43,13 +43,6 @@ EXPECT_EQ(getDetail(*Builder.TakeString()), "result"); } -TEST_F(CompletionStringTest, FilterText) { - Builder.AddTypedTextChunk("typed"); - Builder.AddTypedTextChunk("redundant typed no no"); - auto *S = Builder.TakeString(); - EXPECT_EQ(getFilterText(*S), "typed"); -} - TEST_F(CompletionStringTest, Documentation) { Builder.addBriefComment("This is ignored"); EXPECT_EQ(formatDocumentation(*Builder.TakeString(), "Is this brief?"), @@ -115,7 +108,6 @@ EXPECT_EQ(Label, "Foo(p1, p2)"); EXPECT_EQ(InsertText, "Foo(${1:p1}, ${2:p2})"); EXPECT_EQ(formatDocumentation(*CCS, "Foo's comment"), "Foo's comment"); - EXPECT_EQ(getFilterText(*CCS), "Foo"); } TEST_F(CompletionStringTest, EscapeSnippet) {