Index: clangd/ClangdUnit.cpp =================================================================== --- clangd/ClangdUnit.cpp +++ clangd/ClangdUnit.cpp @@ -245,6 +245,8 @@ for (const auto &S : Command.CommandLine) ArgStrs.push_back(S.c_str()); + VFS->setCurrentWorkingDirectory(Command.Directory); + std::unique_ptr CI; { // FIXME(ibiryukov): store diagnostics from CommandLine when we start Index: clangd/ClangdUnitStore.h =================================================================== --- clangd/ClangdUnitStore.h +++ clangd/ClangdUnitStore.h @@ -79,13 +79,12 @@ IntrusiveRefCntPtr VFS, Func Action) { std::lock_guard Lock(Mutex); - auto Commands = getCompileCommands(CDB, File); - assert(!Commands.empty() && - "getCompileCommands should add default command"); - VFS->setCurrentWorkingDirectory(Commands.front().Directory); - auto It = OpenedFiles.find(File); if (It == OpenedFiles.end()) { + auto Commands = getCompileCommands(CDB, File); + assert(!Commands.empty() && + "getCompileCommands should add default command"); + It = OpenedFiles .insert(std::make_pair(File, ClangdUnit(File, FileContents, ResourceDir, PCHs,