diff --git a/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp b/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp index e8393d17b01e48..b6c83c97407275 100644 --- a/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp +++ b/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp @@ -61,7 +61,7 @@ Marshaller::fromProtobuf(const FuzzyFindRequest *Request) { Result.Limit = Request->limit(); Result.RestrictForCodeCompletion = Request->restricted_for_code_completion(); for (const auto &Path : Request->proximity_paths()) { - llvm::SmallString<256> LocalPath = llvm::StringRef(*LocalIndexRoot); + llvm::SmallString<256> LocalPath = llvm::StringRef(*RemoteIndexRoot); llvm::sys::path::append(LocalPath, Path); Result.ProximityPaths.push_back(std::string(LocalPath)); } @@ -157,7 +157,7 @@ FuzzyFindRequest Marshaller::toProtobuf(const clangd::FuzzyFindRequest &From) { RPCRequest.set_restricted_for_code_completion(From.RestrictForCodeCompletion); for (const auto &Path : From.ProximityPaths) { llvm::SmallString<256> RelativePath = llvm::StringRef(Path); - if (llvm::sys::path::replace_path_prefix(RelativePath, *RemoteIndexRoot, + if (llvm::sys::path::replace_path_prefix(RelativePath, *LocalIndexRoot, "")) RPCRequest.add_proximity_paths(llvm::sys::path::convert_to_slash( RelativePath, llvm::sys::path::Style::posix)); diff --git a/clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp b/clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp index 6cc08144bef8d3..7db7c03d61c9b8 100644 --- a/clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp +++ b/clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp @@ -282,16 +282,16 @@ TEST(RemoteMarshallingTest, IncludeHeaderURIs) { TEST(RemoteMarshallingTest, FuzzyFindRequestSerialization) { clangd::FuzzyFindRequest Request; - Request.ProximityPaths = {testPath("remote/Header.h"), - testPath("remote/subdir/OtherHeader.h"), - testPath("notremote/File.h"), "Not a Path."}; - Marshaller ProtobufMarshaller(testPath("remote/"), testPath("home/")); + Request.ProximityPaths = {testPath("local/Header.h"), + testPath("local/subdir/OtherHeader.h"), + testPath("remote/File.h"), "Not a Path."}; + Marshaller ProtobufMarshaller(testPath("remote/"), testPath("local/")); auto Serialized = ProtobufMarshaller.toProtobuf(Request); EXPECT_EQ(Serialized.proximity_paths_size(), 2); auto Deserialized = ProtobufMarshaller.fromProtobuf(&Serialized); EXPECT_THAT(Deserialized.ProximityPaths, - testing::ElementsAre(testPath("home/Header.h"), - testPath("home/subdir/OtherHeader.h"))); + testing::ElementsAre(testPath("remote/Header.h"), + testPath("remote/subdir/OtherHeader.h"))); } TEST(RemoteMarshallingTest, RelativePathToURITranslation) {