From af98376dc0615f7276732c0ae120be1ae6f53917 Mon Sep 17 00:00:00 2001 From: Eran Ifrah Date: Sat, 11 Jan 2025 22:52:12 +0200 Subject: [PATCH] Quick find bar: do not show the find/replace history menu if there is none Quick find bar: when choosing entry from the history menu, place the caret after the text inserted Signed-off-by: Eran Ifrah --- LiteEditor/quickfindbar.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/LiteEditor/quickfindbar.cpp b/LiteEditor/quickfindbar.cpp index eb4699308b..aaf5df2a7a 100644 --- a/LiteEditor/quickfindbar.cpp +++ b/LiteEditor/quickfindbar.cpp @@ -1137,6 +1137,9 @@ bool QuickFindBar::HandleKeyboardShortcuts(wxKeyEvent& event) void QuickFindBar::ShowMenuForFindCtrl() { + if (m_findHistory.m_commands.empty()) { + return; + } wxMenu menu; for (const auto& word : m_findHistory.m_commands) { int resource_id = wxXmlResource::GetXRCID(word); @@ -1146,6 +1149,7 @@ void QuickFindBar::ShowMenuForFindCtrl() [this, word](wxCommandEvent& event) { wxUnusedVar(event); m_textCtrlFind->SetValue(word); + m_textCtrlFind->SetInsertionPointEnd(); }, resource_id); } @@ -1155,6 +1159,10 @@ void QuickFindBar::ShowMenuForFindCtrl() void QuickFindBar::ShowMenuForReplaceCtrl() { + if (m_replaceHistory.m_commands.empty()) { + return; + } + wxMenu menu; for (const auto& word : m_replaceHistory.m_commands) { int resource_id = wxXmlResource::GetXRCID(word); @@ -1164,6 +1172,7 @@ void QuickFindBar::ShowMenuForReplaceCtrl() [this, word](wxCommandEvent& event) { wxUnusedVar(event); m_textCtrlReplace->SetValue(word); + m_textCtrlReplace->SetInsertionPointEnd(); }, resource_id); }