diff --git a/clang-tools-extra/clangd/CodeComplete.cpp b/clang-tools-extra/clangd/CodeComplete.cpp --- a/clang-tools-extra/clangd/CodeComplete.cpp +++ b/clang-tools-extra/clangd/CodeComplete.cpp @@ -861,7 +861,7 @@ case CodeCompletionResult::RK_Macro: return Result.Macro->getName(); case CodeCompletionResult::RK_Pattern: - return Result.Pattern->getTypedText(); + break; } auto *CCS = codeCompletionString(Result); const CodeCompletionString::Chunk *OnlyText = nullptr; diff --git a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp --- a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp +++ b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp @@ -3131,6 +3131,26 @@ EXPECT_THAT(C, ElementsAre(signature("(char)c secondArgument:(id)object"))); } +TEST(CompletionTest, ObjectiveCMethodDeclarationFilterOnEntireSelector) { + auto Results = completions(R"objc( + @interface Foo + - (int)valueForCharacter:(char)c secondArgument:(id)object; + @end + @implementation Foo + secondArg^ + @end + )objc", + /*IndexSymbols=*/{}, + /*Opts=*/{}, "Foo.m"); + + auto C = Results.Completions; + EXPECT_THAT(C, ElementsAre(named("valueForCharacter:"))); + EXPECT_THAT(C, ElementsAre(filterText("valueForCharacter:secondArgument:"))); + EXPECT_THAT(C, ElementsAre(kind(CompletionItemKind::Method))); + EXPECT_THAT(C, ElementsAre(qualifier("- (int)"))); + EXPECT_THAT(C, ElementsAre(signature("(char)c secondArgument:(id)object"))); +} + TEST(CompletionTest, ObjectiveCMethodDeclarationPrefixTyped) { auto Results = completions(R"objc( @interface Foo