Skip to content

Commit

Permalink
Fix global search searching text in images.
Browse files Browse the repository at this point in the history
  • Loading branch information
SpartanJ committed Dec 6, 2024
1 parent f20017f commit 88f38c3
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/tools/ecode/globalsearchcontroller.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "globalsearchcontroller.hpp"
#include "ecode.hpp"
#include "globalsearchcontroller.hpp"
#include "uitreeviewglobalsearch.hpp"

namespace ecode {
Expand Down Expand Up @@ -664,6 +664,23 @@ void GlobalSearchController::doGlobalSearch( String text, String filter, bool ca
std::vector<std::shared_ptr<TextDocument>> openDocs;
mSplitter->forEachDocSharedPtr(
[&openDocs]( auto doc ) { openDocs.emplace_back( std::move( doc ) ); } );
auto filters = parseGlobMatches( filter );
auto imageExts = Image::getImageExtensionsSupported();
imageExts.erase( std::remove_if( imageExts.begin(), imageExts.end(),
[]( const std::string& ext ) { return ext == "svg"; } ),
imageExts.end() );
filters.reserve( filters.size() + imageExts.size() );
for ( const auto& ext : imageExts ) {
// If user explicitly requested to filter some extension, respect it and do not add the
// ignore for it.
std::string extGlob( "*." + ext );
if ( std::find_if( filters.begin(), filters.end(),
[&extGlob]( const std::pair<std::string, bool>& filter ) {
return filter.first == extGlob;
} ) != filters.end() )
continue;
filters.emplace_back( extGlob, true );
}

ProjectSearch::find(
mApp->getDirTree()->getFiles(), search,
Expand All @@ -685,8 +702,7 @@ void GlobalSearchController::doGlobalSearch( String text, String filter, bool ca
loader->close();
} );
},
caseSensitive, wholeWord, searchType, parseGlobMatches( filter ),
mApp->getCurrentProject(), openDocs );
caseSensitive, wholeWord, searchType, filters, mApp->getCurrentProject(), openDocs );
}
}

Expand Down

0 comments on commit 88f38c3

Please sign in to comment.