Skip to content
Snippets Groups Projects
Commit 0dddb274 authored by Jeff Young's avatar Jeff Young :flag_ua:
Browse files

Include underscore in word chars.

Fixes #14779
parent cbcaaa00
No related branches found
No related tags found
No related merge requests found
Pipeline #993645339 passed
......@@ -114,6 +114,12 @@ wxString EDA_ITEM::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
}
bool isWordChar( const wxUniChar& c )
{
return wxIsalnum( c ) || c == '_';
}
bool EDA_ITEM::Matches( const wxString& aText, const EDA_SEARCH_DATA& aSearchData ) const
{
wxString text = aText;
......@@ -129,6 +135,12 @@ bool EDA_ITEM::Matches( const wxString& aText, const EDA_SEARCH_DATA& aSearchDat
searchText.MakeUpper();
}
auto isWordChar =
[]( const wxUniChar& c )
{
return wxIsalnum( c ) || c == '_';
};
if( aSearchData.matchMode == EDA_SEARCH_MATCH_MODE::PERMISSIVE )
{
EDA_COMBINED_MATCHER matcher( searchText, CTX_SEARCH );
......@@ -149,8 +161,8 @@ bool EDA_ITEM::Matches( const wxString& aText, const EDA_SEARCH_DATA& aSearchDat
ii = next;
next += searchText.length();
bool startOK = ( ii == 0 || !wxIsalnum( text.GetChar( ii - 1 ) ) );
bool endOK = ( next == (int) text.length() || !wxIsalnum( text.GetChar( next ) ) );
bool startOK = ( ii == 0 || !isWordChar( text.GetChar( ii - 1 ) ) );
bool endOK = ( next == (int) text.length() || !isWordChar( text.GetChar( next ) ) );
if( startOK && endOK )
return true;
......@@ -207,8 +219,8 @@ bool EDA_ITEM::Replace( const EDA_SEARCH_DATA& aSearchData, wxString& aText )
if( aSearchData.matchMode == EDA_SEARCH_MATCH_MODE::WHOLEWORD )
{
startOK = ( ii == 0 || !wxIsalnum( text.GetChar( ii - 1 ) ) );
endOK = ( next == (int) text.length() || !wxIsalnum( text.GetChar( next ) ) );
startOK = ( ii == 0 || !isWordChar( text.GetChar( ii - 1 ) ) );
endOK = ( next == (int) text.length() || !isWordChar( text.GetChar( next ) ) );
}
else
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment