Include underscore in word chars.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/14779
This commit is contained in:
parent
cbcaaa001c
commit
0dddb27408
|
@ -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
|
bool EDA_ITEM::Matches( const wxString& aText, const EDA_SEARCH_DATA& aSearchData ) const
|
||||||
{
|
{
|
||||||
wxString text = aText;
|
wxString text = aText;
|
||||||
|
@ -129,6 +135,12 @@ bool EDA_ITEM::Matches( const wxString& aText, const EDA_SEARCH_DATA& aSearchDat
|
||||||
searchText.MakeUpper();
|
searchText.MakeUpper();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto isWordChar =
|
||||||
|
[]( const wxUniChar& c )
|
||||||
|
{
|
||||||
|
return wxIsalnum( c ) || c == '_';
|
||||||
|
};
|
||||||
|
|
||||||
if( aSearchData.matchMode == EDA_SEARCH_MATCH_MODE::PERMISSIVE )
|
if( aSearchData.matchMode == EDA_SEARCH_MATCH_MODE::PERMISSIVE )
|
||||||
{
|
{
|
||||||
EDA_COMBINED_MATCHER matcher( searchText, CTX_SEARCH );
|
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;
|
ii = next;
|
||||||
next += searchText.length();
|
next += searchText.length();
|
||||||
|
|
||||||
bool startOK = ( ii == 0 || !wxIsalnum( text.GetChar( ii - 1 ) ) );
|
bool startOK = ( ii == 0 || !isWordChar( text.GetChar( ii - 1 ) ) );
|
||||||
bool endOK = ( next == (int) text.length() || !wxIsalnum( text.GetChar( next ) ) );
|
bool endOK = ( next == (int) text.length() || !isWordChar( text.GetChar( next ) ) );
|
||||||
|
|
||||||
if( startOK && endOK )
|
if( startOK && endOK )
|
||||||
return true;
|
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 )
|
if( aSearchData.matchMode == EDA_SEARCH_MATCH_MODE::WHOLEWORD )
|
||||||
{
|
{
|
||||||
startOK = ( ii == 0 || !wxIsalnum( text.GetChar( ii - 1 ) ) );
|
startOK = ( ii == 0 || !isWordChar( text.GetChar( ii - 1 ) ) );
|
||||||
endOK = ( next == (int) text.length() || !wxIsalnum( text.GetChar( next ) ) );
|
endOK = ( next == (int) text.length() || !isWordChar( text.GetChar( next ) ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue