diff --git a/clang-tools-extra/clangd/ConfigCompile.cpp b/clang-tools-extra/clangd/ConfigCompile.cpp --- a/clang-tools-extra/clangd/ConfigCompile.cpp +++ b/clang-tools-extra/clangd/ConfigCompile.cpp @@ -363,6 +363,10 @@ if (P.Path.empty() || !pathStartsWith(Spec.MountPoint, P.Path, llvm::sys::path::Style::posix)) return; + if (llvm::StringRef(Spec.Location).equals_lower("none")) { + C.Index.External.reset(); + return; + } C.Index.External = Spec; // Disable background indexing for the files under the mountpoint. // Note that this will overwrite statements in any previous fragments diff --git a/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp b/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp --- a/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp +++ b/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp @@ -335,6 +335,20 @@ #endif } +TEST_F(ConfigCompileTests, ExternalBlockDisableWithNone) { + Fragment::IndexBlock::ExternalBlock External; + External.File.emplace("None"); + Frag.Index.External = std::move(External); + compileAndApply(); + EXPECT_FALSE(Conf.Index.External.hasValue()); + + External = {}; + External.Server.emplace("None"); + Frag.Index.External = std::move(External); + compileAndApply(); + EXPECT_FALSE(Conf.Index.External.hasValue()); +} + TEST_F(ConfigCompileTests, ExternalBlockErrOnNoSource) { Frag.Index.External.emplace(Fragment::IndexBlock::ExternalBlock{}); compileAndApply();