logic: fixed bug where adding an empty include path excludes everything

This commit is contained in:
mlangkabel
2018-04-10 15:52:02 +02:00
parent 8ce17dec8d
commit 648caa9c35
4 changed files with 40 additions and 38 deletions
+34 -32
View File
@@ -157,52 +157,54 @@ std::vector<FilePathFilter> SourceGroupSettings::getExcludeFiltersExpandedAndAbs
{
std::vector<FilePathFilter> result;
for (const FilePathFilter& filter : m_excludeFilters)
for (const std::wstring& filterString : m_excludeFilters)
{
const std::wstring filterString = filter.wstr();
const size_t wildcardPos = filterString.find(L"*");
if (wildcardPos != filterString.npos)
if (!filterString.empty())
{
std::wsmatch match;
if (std::regex_search(filterString, match, std::wregex(L"[\\\\/]")) && !match.empty() &&
match.position(0) < int(wildcardPos))
const size_t wildcardPos = filterString.find(L"*");
if (wildcardPos != filterString.npos)
{
const FilePath p = m_projectSettings->makePathExpandedAndAbsolute(FilePath(match.prefix().str()));
std::wsmatch match;
if (std::regex_search(filterString, match, std::wregex(L"[\\\\/]")) && !match.empty() &&
match.position(0) < int(wildcardPos))
{
const FilePath p = m_projectSettings->makePathExpandedAndAbsolute(FilePath(match.prefix().str()));
std::set<FilePath> symLinkPaths = FileSystem::getSymLinkedDirectories(p);
symLinkPaths.insert(p);
utility::append(result,
utility::convert<FilePath, FilePathFilter>(
utility::toVector(symLinkPaths),
[match](const FilePath& filePath)
{
return FilePathFilter(filePath.wstr() + L"/" + match.suffix().str());
}
)
);
}
else
{
result.push_back(FilePathFilter(filterString));
}
}
else
{
const FilePath p = m_projectSettings->makePathExpandedAndAbsolute(FilePath(filterString));
const bool isFile = p.exists() && !p.isDirectory();
std::set<FilePath> symLinkPaths = FileSystem::getSymLinkedDirectories(p);
symLinkPaths.insert(p);
utility::append(result,
utility::convert<FilePath, FilePathFilter>(
utility::toVector(symLinkPaths),
[match](const FilePath& filePath)
[isFile](const FilePath& filePath)
{
return FilePathFilter(filePath.wstr() + L"/" + match.suffix().str());
return FilePathFilter(filePath.wstr() + (isFile ? L"" : L"**"));
}
)
);
}
else
{
result.push_back(filter);
}
}
else
{
const FilePath p = m_projectSettings->makePathExpandedAndAbsolute(FilePath(filterString));
const bool isFile = p.exists() && !p.isDirectory();
std::set<FilePath> symLinkPaths = FileSystem::getSymLinkedDirectories(p);
symLinkPaths.insert(p);
utility::append(result,
utility::convert<FilePath, FilePathFilter>(
utility::toVector(symLinkPaths),
[isFile](const FilePath& filePath)
{
return FilePathFilter(filePath.wstr() + (isFile ? L"" : L"**"));
}
)
);
}
}
+1 -1
View File
@@ -9,7 +9,7 @@
class FilePathFilter
{
public:
FilePathFilter(const std::wstring& filterString);
explicit FilePathFilter(const std::wstring& filterString);
std::wstring wstr() const;
+3 -3
View File
@@ -68,8 +68,8 @@ std::vector<std::shared_ptr<IndexerCommand>> SourceGroupCxxCdb::getIndexerComman
const std::vector<std::wstring> compilerFlags = m_settings->getCompilerFlags();
std::set<FilePath> indexedPaths = getIndexedPaths();
std::set<FilePathFilter> excludeFilters = getExcludeFilters();
const std::set<FilePath> indexedPaths = getIndexedPaths();
const std::set<FilePathFilter> excludeFilters = getExcludeFilters();
std::vector<std::shared_ptr<IndexerCommand>> indexerCommands;
@@ -108,7 +108,7 @@ std::vector<std::shared_ptr<IndexerCommand>> SourceGroupCxxCdb::getIndexerComman
indexerCommands.push_back(std::make_shared<IndexerCommandCxxCdb>(
sourcePath,
indexedPaths,
getExcludeFilters(),
excludeFilters,
FilePath(utility::decodeFromUtf8(command.Directory)),
utility::concat(
utility::convert<std::string, std::wstring>(command.CommandLine, [](const std::string& arg) { return utility::decodeFromUtf8(arg); }),
+2 -2
View File
@@ -51,8 +51,8 @@ std::vector<std::shared_ptr<IndexerCommand>> SourceGroupCxxEmpty::getIndexerComm
utility::append(compilerFlags, m_settings->getCompilerFlags());
std::set<FilePath> indexedPaths = getIndexedPaths();
std::set<FilePathFilter> excludeFilters = getExcludeFilters();
const std::set<FilePath> indexedPaths = getIndexedPaths();
const std::set<FilePathFilter> excludeFilters = getExcludeFilters();
std::vector<std::shared_ptr<IndexerCommand>> indexerCommands;
for (const FilePath& sourcePath: getAllSourceFilePaths())