mirror of
https://github.com/MaskRay/ccls.git
synced 2025-06-07 16:54:54 +00:00
fix index error when there is a soft link file as https://github.com/MaskRay/ccls/pull/643
This commit is contained in:
parent
8cf8a3c4a4
commit
88cd914342
@ -25,6 +25,7 @@
|
|||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
using namespace clang;
|
using namespace clang;
|
||||||
|
|
||||||
@ -1355,6 +1356,11 @@ index(SemaManager *manager, WorkingFiles *wfiles, VFS *vfs,
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string abs_main;
|
||||||
|
if (std::filesystem::exists(main)) {
|
||||||
|
abs_main = std::filesystem::canonical(main);
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<std::unique_ptr<IndexFile>> result;
|
std::vector<std::unique_ptr<IndexFile>> result;
|
||||||
for (auto &it : param.uid2file) {
|
for (auto &it : param.uid2file) {
|
||||||
if (!it.second.db)
|
if (!it.second.db)
|
||||||
@ -1392,6 +1398,13 @@ index(SemaManager *manager, WorkingFiles *wfiles, VFS *vfs,
|
|||||||
entry->dependencies[llvm::CachedHashStringRef(intern(path))] =
|
entry->dependencies[llvm::CachedHashStringRef(intern(path))] =
|
||||||
file.mtime;
|
file.mtime;
|
||||||
}
|
}
|
||||||
|
std::string abs_entry;
|
||||||
|
if (std::filesystem::exists(entry->path)) {
|
||||||
|
abs_entry = std::filesystem::canonical(entry->path);
|
||||||
|
if (abs_entry == abs_main){
|
||||||
|
entry->path = main;
|
||||||
|
}
|
||||||
|
}
|
||||||
result.push_back(std::move(entry));
|
result.push_back(std::move(entry));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user