diff --git a/src/tools/ecode/projectdirectorytree.cpp b/src/tools/ecode/projectdirectorytree.cpp index 8d8da2691..5851a86bf 100644 --- a/src/tools/ecode/projectdirectorytree.cpp +++ b/src/tools/ecode/projectdirectorytree.cpp @@ -460,13 +460,29 @@ void ProjectDirectoryTree::addFile( const FileInfo& file ) { if ( mIgnoreHidden && file.isHidden() ) return; Lock rl( mMatchingMutex ); - Lock l( mFilesMutex ); - std::string directory( file.getFilepath() ); + const std::string& directoryEntry = file.getFilepath(); + IgnoreMatcherManager matcher( getIgnoreMatcherFromPath( directoryEntry ) ); + if ( matcher.foundMatch() && matcher.match( file ) ) { + if ( !mAllowedMatcher || !mAllowedMatcher->hasPatterns() ) + return; + std::string_view localPath( directoryEntry ); + if ( String::startsWith( directoryEntry, mAllowedMatcher->getPath() ) ) + localPath.remove_prefix( mAllowedMatcher->getPath().size() ); + if ( !mAllowedMatcher->match( localPath ) ) + return; + } else if ( mDisallowedMatcher && mDisallowedMatcher->hasPatterns() ) { + std::string_view localPath( directoryEntry ); + if ( String::startsWith( directoryEntry, mDisallowedMatcher->getPath() ) ) + localPath.remove_prefix( mDisallowedMatcher->getPath().size() ); + if ( mDisallowedMatcher->match( localPath ) ) + return; + } + std::string directory( directoryEntry ); FileSystem::dirAddSlashAtEnd( directory ); + Lock l( mFilesMutex ); std::vector files; std::vector names; std::set info; - IgnoreMatcherManager matcher( getIgnoreMatcherFromPath( directory ) ); { Lock ld( mDirectoriesMutex ); mDirectories.emplace_back( directory );