summarylogtreecommitdiffstats
path: root/lsp-remove-files-from-cdb.patch
blob: d3f0ba4ae5c94d6f6b5cb1fcecf88154128fd073 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index 7d646d6f7583..c854bcc017f1 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -1455,7 +1455,10 @@ void ClangdLSPServer::applyConfiguration(
         tooling::CompileCommand(std::move(Command.workingDirectory), File,
                                 std::move(Command.compilationCommand),
                                 /*Output=*/"");
-    if (CDB->setCompileCommand(File, std::move(Cmd))) {
+    if (Cmd.CommandLine.empty() && Cmd.Directory.empty()) {
+      if (CDB->setCompileCommand(File, std::nullopt))
+        ModifiedFiles.insert(File);
+    } else if (CDB->setCompileCommand(File, std::move(Cmd))) {
       ModifiedFiles.insert(File);
     }
   }