From eaf151075ccd01bfe75ce47e1b6b844463511918 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 24 Sep 2020 18:46:01 +0100 Subject: [PATCH] Correctly de-highlight found items when closing Find dialog. Fixes https://gitlab.com/kicad/code/kicad/issues/5775 --- eeschema/dialogs/dialog_schematic_find.cpp | 23 ++++++++++++++++------ eeschema/sch_edit_frame.cpp | 2 ++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/eeschema/dialogs/dialog_schematic_find.cpp b/eeschema/dialogs/dialog_schematic_find.cpp index fca65bf8de..a6ed74064b 100644 --- a/eeschema/dialogs/dialog_schematic_find.cpp +++ b/eeschema/dialogs/dialog_schematic_find.cpp @@ -96,9 +96,6 @@ void DIALOG_SCH_FIND::OnClose( wxCloseEvent& aEvent ) { // Notify the SCH_EDIT_FRAME m_frame->OnFindDialogClose(); - - // Notify the controller - m_findDirty = true; } @@ -249,7 +246,7 @@ void DIALOG_SCH_FIND::OnFind( wxCommandEvent& aEvent ) m_comboFind->SetSelection( 0 ); } - m_editorControl->FindNext( ACTIONS::findNext.MakeEvent()); + m_editorControl->FindNext( ACTIONS::findNext.MakeEvent() ); } @@ -271,14 +268,28 @@ void DIALOG_SCH_FIND::OnReplace( wxCommandEvent& aEvent ) } if( aEvent.GetId() == wxID_REPLACE ) - m_editorControl->ReplaceAndFindNext( ACTIONS::replaceAndFindNext.MakeEvent()); + m_editorControl->ReplaceAndFindNext( ACTIONS::replaceAndFindNext.MakeEvent() ); else if( aEvent.GetId() == wxID_REPLACE_ALL ) - m_editorControl->ReplaceAll( ACTIONS::replaceAll.MakeEvent()); + m_editorControl->ReplaceAll( ACTIONS::replaceAll.MakeEvent() ); } wxArrayString DIALOG_SCH_FIND::GetFindEntries() const { + int index = m_comboFind->FindString( m_comboFind->GetValue(), true ); + + if( index == wxNOT_FOUND ) + { + m_comboFind->Insert( m_comboFind->GetValue(), 0 ); + } + else if( index != 0 ) + { + /* Move the search string to the top of the list if it isn't already there. */ + wxString tmp = m_comboFind->GetValue(); + m_comboFind->Delete( index ); + m_comboFind->Insert( tmp, 0 ); + } + return m_comboFind->GetStrings(); } diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 7773edca14..c80983888f 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -824,6 +824,8 @@ void SCH_EDIT_FRAME::OnFindDialogClose() m_findReplaceDialog->Destroy(); m_findReplaceDialog = nullptr; + + m_toolManager->RunAction( ACTIONS::updateFind, true ); }