Skip to content

Commit 1ac0cef

Browse files
heffneilclaude
andauthored
Layout filters: match multiple search terms (Models, Groups, Controllers) (#6945)
* Layout filters: whitespace-tokenized AND matching (Models, Groups, Controllers) The Layout Models/Groups filter (LayoutPanel::MatchesFilter) and the Controllers filter (ControllerListPanel::ControllerMatchesFilter) treated the whole search box as one string, so 'midwest pumpkin' never matched 'Midwest-Coro-Pumpkin'. Split the filter on whitespace and require every term to appear in the name (any order), matching the vendor-catalog and picker-dialog filters. A single term keeps the existing behaviour, including the regex power-search. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * Drop explanatory comments per review; behavior is described in the commit message Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 242f715 commit 1ac0cef

2 files changed

Lines changed: 26 additions & 6 deletions

File tree

src-ui-wx/layout/ControllerListPanel.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <wx/dnd.h>
1717
#include <wx/menu.h>
1818
#include <wx/msgdlg.h>
19+
#include <wx/tokenzr.h>
1920
#include <wx/srchctrl.h>
2021
#include <wx/stopwatch.h>
2122
#include <wx/settings.h>
@@ -540,10 +541,19 @@ void ControllerListPanel::OnFullColumnsClick(wxCommandEvent& event) {
540541
bool ControllerListPanel::ControllerMatchesFilter(const Controller* controller) const {
541542
if (_controllerFilterCtrl == nullptr || _controllerFilterString.IsEmpty()) return true;
542543

543-
if (_controllerFilterRegexValid)
544-
return _controllerFilterRegex.Matches(controller->GetName());
544+
wxArrayString terms = wxStringTokenize(_controllerFilterString.Lower(), " \t");
545+
if (terms.size() <= 1) {
546+
if (_controllerFilterRegexValid)
547+
return _controllerFilterRegex.Matches(controller->GetName());
548+
return wxString(controller->GetName()).Lower().Contains(_controllerFilterString.Lower());
549+
}
545550

546-
return wxString(controller->GetName()).Lower().Contains(_controllerFilterString.Lower());
551+
const wxString name = wxString(controller->GetName()).Lower();
552+
for (const auto& term : terms) {
553+
if (!name.Contains(term))
554+
return false;
555+
}
556+
return true;
547557
}
548558

549559
void ControllerListPanel::OnSelectionChanged(wxTreeListEvent& event) {

src-ui-wx/layout/LayoutPanel.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <wx/propgrid/advprops.h>
3232
#include <wx/tglbtn.h>
3333
#include <wx/srchctrl.h>
34+
#include <wx/tokenzr.h>
3435
#include <wx/checklst.h>
3536
#include <pugixml.hpp>
3637
#include <cmath>
@@ -13185,10 +13186,19 @@ void LayoutPanel::OnGroupFilterTextChanged(wxCommandEvent& event) {
1318513186
bool LayoutPanel::MatchesFilter(Model* model, const wxString& filterString, const wxRegEx& filterRegex, bool filterRegexValid) {
1318613187
if (filterString.IsEmpty()) return true;
1318713188

13188-
if (filterRegexValid)
13189-
return filterRegex.Matches(model->GetName());
13189+
wxArrayString terms = wxStringTokenize(filterString.Lower(), " \t");
13190+
if (terms.size() <= 1) {
13191+
if (filterRegexValid)
13192+
return filterRegex.Matches(model->GetName());
13193+
return wxString(model->GetName()).Lower().Contains(filterString.Lower());
13194+
}
1319013195

13191-
return wxString(model->GetName()).Lower().Contains(filterString.Lower());
13196+
const wxString name = wxString(model->GetName()).Lower();
13197+
for (const auto& term : terms) {
13198+
if (!name.Contains(term))
13199+
return false;
13200+
}
13201+
return true;
1319213202
}
1319313203

1319413204
bool LayoutPanel::ModelMatchesFilter(Model* model) const {

0 commit comments

Comments
 (0)