Skip to content

Conversation

@goughjo02
Copy link

The basics

The details

Resolves

Fixes #2645

Proposed Changes

  • Include the final trigram when generating search tokens to prevent partial matches on long queries.
  • Add a regression test covering the “conso” false positive case.
  • Expand BlockSearcher tests for short/empty input, underscore normalization, dropdown alt text indexing, and disambiguation between similar blocks.

Reason for Changes

  • Prevent toolbox search from returning false positives for queries longer than three characters and improve overall search accuracy.

Test Coverage

  • npm test -- --runInBand (blockly-scripts test)

Documentation

  • No documentation updates needed.

Additional Information

  • Additional tests define temporary blocks/dropdowns to exercise edge cases; no user-facing behavior changes beyond correcting search results.

add regression test asserting long queries require their trailing trigram
adjust trigram loop to cover the last trigram so partial matches stop passing
cover trigram edge cases, underscore normalization, dropdown alt text, and disambiguation of similar blocks
@gonfunko gonfunko self-assigned this Dec 12, 2025
@gonfunko
Copy link
Contributor

Thank you for identifying and reporting this issue and sending a fix! I really appreciate the improved tests as well. I just had two minor questions, and if you could run npm run format and commit the results of that to make the linter happy I think we should be good to merge this.

searcher.indexBlocks([blockInfo]);

assert.sameMembers(
searcher.blockTypesMatching('custom block with underscore'),
Copy link
Contributor

Choose a reason for hiding this comment

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

If the test is verifying that underscores in the block type get treated as spaces, should this be 'searcher underscore block'? As written this would match the unmodified message, but not verify the normalization of the block type.

options: [
[
{
src: 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEA',
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't appear to actually be a valid image; if it doesn't otherwise cause problems, can you set src to '' here and below to avoid confusion as to what this is and whether the particular value is relevant to the test case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Toolbox search: long queries drop the last trigram, causing false positives (e.g. “conso” matches “math constrain”)

2 participants