Skip to content

Commit 697de1c

Browse files
committed
[clangd] Fix off-by-one in CodeComplete and assertion in Dex
llvm-svn: 365955
1 parent 77dd8a7 commit 697de1c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

clang-tools-extra/clangd/CodeComplete.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,12 +1391,12 @@ class CodeCompleteFlow {
13911391
unsigned RangeEnd = HeuristicPrefix.Qualifier.begin() - Content.data(),
13921392
RangeBegin = RangeEnd;
13931393
for (size_t I = 0; I < 3 && RangeBegin > 0; ++I) {
1394-
auto PrevNL = Content.rfind('\n', RangeBegin - 1);
1394+
auto PrevNL = Content.rfind('\n', RangeBegin);
13951395
if (PrevNL == StringRef::npos) {
13961396
RangeBegin = 0;
13971397
break;
13981398
}
1399-
RangeBegin = PrevNL + 1;
1399+
RangeBegin = PrevNL;
14001400
}
14011401

14021402
ContextWords = collectWords(Content.slice(RangeBegin, RangeEnd));

clang-tools-extra/clangd/index/dex/Dex.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,9 @@ std::vector<std::string> generateProximityURIs(llvm::StringRef URIPath) {
316316
// FIXME(kbobyrev): Parsing and encoding path to URIs is not necessary and
317317
// could be optimized.
318318
Body = llvm::sys::path::parent_path(Body, llvm::sys::path::Style::posix);
319-
URI TokenURI(ParsedURI->scheme(), ParsedURI->authority(), Body);
320319
if (!Body.empty())
321-
Result.emplace_back(TokenURI.toString());
320+
Result.emplace_back(
321+
URI(ParsedURI->scheme(), ParsedURI->authority(), Body).toString());
322322
}
323323
return Result;
324324
}

0 commit comments

Comments
 (0)