Don't trim both back and front if there's only one char.

Fixes https://gitlab.com/kicad/code/kicad/issues/5357
This commit is contained in:
Jeff Young 2020-08-26 00:02:11 +01:00
parent a55eaec28c
commit 40d7940d52
1 changed files with 4 additions and 2 deletions

View File

@ -323,11 +323,13 @@ void SelectReferenceNumber( wxTextEntry* aTextEntry )
while( !num.IsEmpty() && ( !isdigit( num.Last() ) || !isdigit( num.GetChar( 0 ) ) ) ) while( !num.IsEmpty() && ( !isdigit( num.Last() ) || !isdigit( num.GetChar( 0 ) ) ) )
{ {
// Trim non-digit from end
if( !isdigit( num.Last() ) ) if( !isdigit( num.Last() ) )
num.RemoveLast(); num.RemoveLast();
if( !isdigit( num.GetChar ( 0 ) ) ) // Trim non-digit from the start
num = num.Right( num.Length() - 1); if( !num.IsEmpty() && !isdigit( num.GetChar( 0 ) ) )
num = num.Right( num.Length() - 1 );
} }
aTextEntry->SetSelection( ref.Find( num ), ref.Find( num ) + num.Length() ); aTextEntry->SetSelection( ref.Find( num ), ref.Find( num ) + num.Length() );