-
Notifications
You must be signed in to change notification settings - Fork 663
Description
Check for duplicates
- I have searched for similar issues before opening a new one.
Component
toolbox-search plugin (plugins/toolbox-search), version 3.1.3 (current main)
Description
When searching in the toolbox search category, queries longer than three characters can match blocks that don’t contain the full query. Example: typing “conso” returns the built-in math_constrain block even though its text is “math constrain”. The trigram generator in src/block_searcher.ts stops one character early:
for (let start = 0; start < normalizedInput.length - 3; start++)
so “conso” produces only ["con", "ons"] (missing nso). Because matches are the intersection of generated trigrams, dropping the final trigram broadens results and yields false positives. Expected: include the final trigram (loop should use <=), so “conso” would not match “math constrain”.
I’m happy to work on a fix; the minimal change is to adjust the trigram loop in src/block_searcher.ts to include the final trigram (<= normalizedInput.length - 3).
Reproduction steps
- Install @blockly/toolbox-search and include a toolbox that contains the default math blocks (so math_constrain is present).
- Add the search category to the toolbox: { kind: 'search', name: 'Search', contents: [] }.
- Open the search category and type conso.
- Observe that math_constrain appears in the results.
Expected result
No matches for “conso” unless a block actually contains that substring.
Actual result
math_constrain (and any block with “con”+“ons” but not the full “conso”) appears.
Stack trace
Screenshots
No response