mirror of
https://github.com/MaskRay/ccls.git
synced 2025-06-06 16:24:54 +00:00
fix when workspace has soft link; eg: /home/Abbyyan->/data/home/Abbyan and open with /home/Abbyyan
This commit is contained in:
parent
99f0b402a7
commit
ace782f2fa
@ -20,10 +20,19 @@ using namespace clang;
|
||||
using namespace llvm;
|
||||
|
||||
namespace ccls {
|
||||
bool checkFolder(std::string &path) {
|
||||
for (auto &[root, real] : g_config->workspaceFolders)
|
||||
if (StringRef(path).startswith(root))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string pathFromFileEntry(const FileEntry &file) {
|
||||
SmallString<128> path(file.getName());
|
||||
sys::path::remove_dots(path, /*remove_dot_dot=*/true);
|
||||
std::string ret(path.str());
|
||||
if (checkFolder(ret))
|
||||
return ret;
|
||||
// Resolve symlinks outside of workspace folders, e.g. /usr/include/c++/7.3.0
|
||||
return normalizeFolder(ret) ? ret : realPath(ret);
|
||||
}
|
||||
@ -113,7 +122,7 @@ buildCompilerInvocation(const std::string &main, std::vector<const char *> args,
|
||||
const driver::JobList &jobs = comp->getJobs();
|
||||
bool offload_compilation = false;
|
||||
if (jobs.size() > 1) {
|
||||
for (auto &a : comp->getActions()){
|
||||
for (auto &a : comp->getActions()) {
|
||||
// On MacOSX real actions may end up being wrapped in BindArchAction
|
||||
if (isa<driver::BindArchAction>(a))
|
||||
a = *a->input_begin();
|
||||
|
@ -20,6 +20,8 @@ namespace vfs = clang::vfs;
|
||||
namespace ccls {
|
||||
std::string pathFromFileEntry(const clang::FileEntry &file);
|
||||
|
||||
bool checkFolder(std::string &path);
|
||||
|
||||
bool isInsideMainFile(const clang::SourceManager &sm, clang::SourceLocation sl);
|
||||
|
||||
Range fromCharSourceRange(const clang::SourceManager &sm,
|
||||
|
Loading…
Reference in New Issue
Block a user