From 2bc8c0ace5e927bc7a5bd7a630d436f488e79a38 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Thu, 9 Mar 2023 11:47:57 -0800 Subject: [PATCH] Fix Eeschema Find/Replace Find/Replace skipped elements that were inside the same symbol, preventing a full search of the schematic. --- eeschema/tools/sch_editor_control.cpp | 57 ++++++++++----------------- 1 file changed, 20 insertions(+), 37 deletions(-) diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index 8f4337ad0e..308ad8c703 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -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( aAfter->GetParent() ); } std::vector sorted_items; for( SCH_ITEM* item : aScreen->Items() ) + { + if( SCH_SYMBOL* sym = dyn_cast( 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( 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( 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( 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; - } - } } }