[clangd] Fix off-by-one in CodeComplete and assertion in Dex

llvm-svn: 365955
This commit is contained in:
Sam McCall 2019-07-12 20:35:41 +00:00
parent 77dd8a7928
commit 697de1c24e
2 changed files with 4 additions and 4 deletions

View File

@ -1391,12 +1391,12 @@ private:
unsigned RangeEnd = HeuristicPrefix.Qualifier.begin() - Content.data(), unsigned RangeEnd = HeuristicPrefix.Qualifier.begin() - Content.data(),
RangeBegin = RangeEnd; RangeBegin = RangeEnd;
for (size_t I = 0; I < 3 && RangeBegin > 0; ++I) { for (size_t I = 0; I < 3 && RangeBegin > 0; ++I) {
auto PrevNL = Content.rfind('\n', RangeBegin - 1); auto PrevNL = Content.rfind('\n', RangeBegin);
if (PrevNL == StringRef::npos) { if (PrevNL == StringRef::npos) {
RangeBegin = 0; RangeBegin = 0;
break; break;
} }
RangeBegin = PrevNL + 1; RangeBegin = PrevNL;
} }
ContextWords = collectWords(Content.slice(RangeBegin, RangeEnd)); ContextWords = collectWords(Content.slice(RangeBegin, RangeEnd));

View File

@ -316,9 +316,9 @@ std::vector<std::string> generateProximityURIs(llvm::StringRef URIPath) {
// FIXME(kbobyrev): Parsing and encoding path to URIs is not necessary and // FIXME(kbobyrev): Parsing and encoding path to URIs is not necessary and
// could be optimized. // could be optimized.
Body = llvm::sys::path::parent_path(Body, llvm::sys::path::Style::posix); Body = llvm::sys::path::parent_path(Body, llvm::sys::path::Style::posix);
URI TokenURI(ParsedURI->scheme(), ParsedURI->authority(), Body);
if (!Body.empty()) if (!Body.empty())
Result.emplace_back(TokenURI.toString()); Result.emplace_back(
URI(ParsedURI->scheme(), ParsedURI->authority(), Body).toString());
} }
return Result; return Result;
} }