[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:45:07 PST 2021
kadircet updated this revision to Diff 319229.
kadircet marked an inline comment as done.
kadircet added a comment.
- Rewrite the condition as suggested
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.319229.patch
Type: text/x-patch
Size: 1383 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210126/99391b3b/attachment.bin>
More information about the cfe-commits
mailing list