[PATCH] D95419: [clangd] Fix filename completion at the end of file
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 26 00:46:20 PST 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG64cdba65bbfa: [clangd] Fix filename completion at the end of file (authored by kadircet).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D95419/new/
https://reviews.llvm.org/D95419
Files:
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -2573,7 +2573,7 @@
}
TEST(CompletionTest, IncludedCompletionKinds) {
- Annotations Test(R"cpp(#include "^")cpp");
+ Annotations Test(R"cpp(#include "^)cpp");
auto TU = TestTU::withCode(Test.code());
TU.AdditionalFiles["sub/bar.h"] = "";
TU.ExtraArgs.push_back("-I" + testPath("sub"));
Index: clang-tools-extra/clangd/CodeComplete.cpp
===================================================================
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -1123,7 +1123,9 @@
// skip all includes in this case; these completions are really simple.
PreambleBounds PreambleRegion =
ComputePreambleBounds(*CI->getLangOpts(), *ContentsBuffer, 0);
- bool CompletingInPreamble = PreambleRegion.Size > Input.Offset;
+ bool CompletingInPreamble = Input.Offset < PreambleRegion.Size ||
+ (!PreambleRegion.PreambleEndsAtStartOfLine &&
+ Input.Offset == PreambleRegion.Size);
if (Input.Patch)
Input.Patch->apply(*CI);
// NOTE: we must call BeginSourceFile after prepareCompilerInstance. Otherwise
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95419.319230.patch
Type: text/x-patch
Size: 1383 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210126/c1c9235a/attachment.bin>
More information about the cfe-commits
mailing list