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 @@ -1831,8 +1831,12 @@ : ReturnType; LSP.deprecated = Deprecated; if (InsertInclude) - LSP.detail += "\n" + InsertInclude->Header; - LSP.documentation = Documentation; + LSP.documentation = llvm::formatv("#include {0}", InsertInclude->Header); + if (!Documentation.empty()) { + if (!LSP.documentation.empty()) + LSP.documentation += "\n"; + LSP.documentation += Documentation; + } LSP.sortText = sortText(Score.Total, Name); LSP.filterText = Name; LSP.textEdit = {CompletionTokenRange, RequiredQualifier + Name}; 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 @@ -1660,8 +1660,8 @@ EXPECT_EQ(R.insertText, "Foo::x"); EXPECT_EQ(R.insertTextFormat, InsertTextFormat::PlainText); EXPECT_EQ(R.filterText, "x"); - EXPECT_EQ(R.detail, "int\n\"foo.h\""); - EXPECT_EQ(R.documentation, "This is x()."); + EXPECT_EQ(R.detail, "int"); + EXPECT_EQ(R.documentation, "#include \"foo.h\"\nThis is x()."); EXPECT_THAT(R.additionalTextEdits, IsEmpty()); EXPECT_EQ(R.sortText, sortText(1.0, "x")); EXPECT_FALSE(R.deprecated); @@ -1683,7 +1683,8 @@ C.BundleSize = 2; R = C.render(Opts); - EXPECT_EQ(R.detail, "[2 overloads]\n\"foo.h\""); + EXPECT_EQ(R.detail, "[2 overloads]"); + EXPECT_EQ(R.documentation, "#include \"foo.h\"\nThis is x()."); C.Deprecated = true; R = C.render(Opts);