Handle string escaping for Find/Replace in labels.

Fixes https://gitlab.com/kicad/code/kicad/issues/12789

(cherry picked from commit ae9405a4d3)
This commit is contained in:
Jeff Young 2022-11-04 00:26:30 +00:00
parent a09a3dfe68
commit ede21ed6ae
2 changed files with 22 additions and 9 deletions

View File

@ -665,6 +665,26 @@ wxString SCH_TEXT::GetShownText( int aDepth, bool aAllowExtraText ) const
}
bool SCH_TEXT::Matches( const wxFindReplaceData& aSearchData, void* aAuxData ) const
{
return SCH_ITEM::Matches( UnescapeString( GetText() ), aSearchData );
}
bool SCH_TEXT::Replace( const wxFindReplaceData& aSearchData, void* aAuxData )
{
wxFindReplaceData localSearchData( aSearchData );
if( Type() == SCH_LABEL_T || Type() == SCH_HIER_LABEL_T || Type() == SCH_GLOBAL_LABEL_T )
{
localSearchData.SetFindString( EscapeString( aSearchData.GetFindString(), CTX_NETNAME ) );
localSearchData.SetReplaceString( EscapeString( aSearchData.GetReplaceString(), CTX_NETNAME ) );
}
return EDA_TEXT::Replace( localSearchData );
}
wxString SCH_TEXT::GetSelectMenuText( EDA_UNITS aUnits ) const
{
return wxString::Format( _( "Graphic Text '%s'" ), ShortenedShownText() );

View File

@ -210,15 +210,8 @@ public:
virtual void Rotate90( bool aClockwise );
virtual void MirrorSpinStyle( bool aLeftRight );
bool Matches( const wxFindReplaceData& aSearchData, void* aAuxData ) const override
{
return SCH_ITEM::Matches( GetText(), aSearchData );
}
bool Replace( const wxFindReplaceData& aSearchData, void* aAuxData ) override
{
return EDA_TEXT::Replace( aSearchData );
}
bool Matches( const wxFindReplaceData& aSearchData, void* aAuxData ) const override;
bool Replace( const wxFindReplaceData& aSearchData, void* aAuxData ) override;
virtual bool IsReplaceable() const override { return true; }