Fix Eeschema Find/Replace

Find/Replace skipped elements that were inside the same symbol,
preventing a full search of the schematic.
This commit is contained in:
Seth Hillbrand 2023-03-09 11:47:57 -08:00
parent f439dfb6ea
commit 2bc8c0ace5
1 changed files with 20 additions and 37 deletions

View File

@ -340,15 +340,32 @@ SCH_ITEM* SCH_EDITOR_CONTROL::nextMatch( SCH_SCREEN* aScreen, SCH_SHEET_PATH* aS
if( aAfter != nullptr )
{
past_item = false;
if( aAfter->Type() == SCH_PIN_T || aAfter->Type() == SCH_FIELD_T )
aAfter = static_cast<SCH_ITEM*>( aAfter->GetParent() );
}
std::vector<SCH_ITEM*> sorted_items;
for( SCH_ITEM* item : aScreen->Items() )
{
if( SCH_SYMBOL* sym = dyn_cast<SCH_SYMBOL*>( item ) )
{
for( SCH_FIELD& field : sym->GetFields() )
sorted_items.push_back( &field );
for( SCH_PIN* pin : sym->GetPins() )
sorted_items.push_back( pin );
}
if( SCH_SHEET* sheet = dyn_cast<SCH_SHEET*>( item ) )
{
for( SCH_FIELD& field : sheet->GetFields() )
sorted_items.push_back( &field );
for( SCH_SHEET_PIN* pin : sheet->GetPins() )
sorted_items.push_back( pin );
}
sorted_items.push_back( item );
}
std::sort( sorted_items.begin(), sorted_items.end(),
[&]( SCH_ITEM* a, SCH_ITEM* b )
@ -379,40 +396,6 @@ SCH_ITEM* SCH_EDITOR_CONTROL::nextMatch( SCH_SCREEN* aScreen, SCH_SHEET_PATH* aS
if( item->Matches( aData, aSheet ) )
return item;
if( item->Type() == SCH_SYMBOL_T )
{
SCH_SYMBOL* cmp = static_cast<SCH_SYMBOL*>( item );
for( SCH_FIELD& field : cmp->GetFields() )
{
if( field.Matches( aData, aSheet ) )
return &field;
}
for( SCH_PIN* pin : cmp->GetPins() )
{
if( pin->Matches( aData, aSheet ) )
return pin;
}
}
if( item->Type() == SCH_SHEET_T )
{
SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
for( SCH_FIELD& field : sheet->GetFields() )
{
if( field.Matches( aData, aSheet ) )
return &field;
}
for( SCH_SHEET_PIN* pin : sheet->GetPins() )
{
if( pin->Matches( aData, aSheet ) )
return pin;
}
}
}
}