Skip to content

SearchableListBox: match items containing the query before fuzzy matching - #272

Merged
Felix-Mallinder merged 1 commit into
developfrom
Python_Toolkit-#270-SearchFilterSubstringMatch
Nov 23, 2026
Merged

Felix-Mallinder merged 1 commit into
developfrom
Python_Toolkit-#270-SearchFilterSubstringMatch

Conversation

@Felix-Mallinder

@Felix-Mallinder Felix-Mallinder commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Issues addressed by this PR

Closes #270

SearchableListBox's default_scorer used only the BHoM WeightedRatio fuzzy match. WeightedRatio scales scores down when the item is much longer than the query, so long names (e.g. GBR_London.Gatwick_2050_ASHRAE_RCP8.5.epw for .epw) and short queries (a, lo, 205) fell below min_score and were hidden.

  • An item now matches when it contains every word of the query (case and punctuation ignored). These rank above any fuzzy match and keep their item order.
  • Fuzzy matching is kept as a typo fallback for queries of 4+ characters, still honouring min_score.
  • The previous fuzzy-only scorer is available as fuzzy_scorer.

Test files

Python_Engine/Python/tests/test_bhom_tkinter_ui.py::test_searchable_list_box_fuzzy_matching (new asserts for long items and short queries). All 5 tests in the file pass.

Changelog

  • SearchableListBox filter now shows every item containing the typed words, with fuzzy matching as a fallback for typos.

Additional comments

🤖 Generated with Claude Code

…hing

The default scorer used only the BHoM WeightedRatio fuzzy match, which scales
scores down for long items, so long names and short queries were hidden.
Items containing every word of the query now match first; fuzzy matching is a
typo fallback for queries of 4+ characters. The fuzzy-only scorer is kept as
fuzzy_scorer.

Closes #270

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Felix-Mallinder Felix-Mallinder added the type:bug Error or unexpected behaviour label Nov 20, 2026
@Felix-Mallinder Felix-Mallinder self-assigned this Nov 20, 2026

@SimosManiatis SimosManiatis left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello! So the approach (contains-every-word first, fuzzy as a typo fallback) is simple and works. A few small points:

Punctuation-only queries empty the list. Typing . (the first keystroke of .epw) gives no words, so every item is hidden. Could default_scorer show everything when the query has no alphanumeric characters?

Query words can overlap in the item. 8.5 matches RCP85 and a b matches ab, because each word is checked on its own. Fine for a filter if that's intended, just flagging it.

Nit: the test docstring still says "best first", and the test name ..._fuzzy_matching now mostly covers the contains path.

Ran the tests locally (Py 3.13 and 3.10): all 5 in test_bhom_tkinter_ui.py pass. test_colour_scale_builder.py errors with a Tk init.tcl error when run after the UI tests, but it does the same on develop, so it's not from this PR. Probably worth its own issue.

@Felix-Mallinder

Copy link
Copy Markdown
Contributor Author

@BHoMBot check ready-to-merge

@bhombot-ci

bhombot-ci Bot commented Nov 23, 2026

Copy link
Copy Markdown

@Felix-Mallinder to confirm, the following actions are now queued:

  • check ready-to-merge

There are 399 requests in the queue ahead of you.

@Felix-Mallinder
Felix-Mallinder merged commit a2d1a4c into develop Nov 23, 2026
19 checks passed
@Felix-Mallinder
Felix-Mallinder deleted the Python_Toolkit-#270-SearchFilterSubstringMatch branch November 23, 2026 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug Error or unexpected behaviour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SearchableListBox default filter hides long items and short queries

2 participants