Skip to content

fix(search): escape LIKE wildcards and fix match highlighting#488

Open
leno23 wants to merge 1 commit into
cantino:masterfrom
leno23:fix/underscore-search-panic-441
Open

fix(search): escape LIKE wildcards and fix match highlighting#488
leno23 wants to merge 1 commit into
cantino:masterfrom
leno23:fix/underscore-search-panic-441

Conversation

@leno23
Copy link
Copy Markdown

@leno23 leno23 commented May 25, 2026

Summary

  • Searching for _ with fuzzy matching used SQL LIKE where _ is a single-character wildcard, so unrelated commands (e.g. box-drawing characters) were returned.
  • Highlight indices for exact matches used byte ranges (index..index + cmd.len()), which can fall inside multi-byte UTF-8 characters and panic when rendering results.
  • Escape % and _ in LIKE patterns (ESCAPE '\\') and compute highlight indices at Unicode character boundaries.

Fixes #441

Test plan

  • cargo test
  • Added unit tests for escape_like, char-boundary match indices, and fuzzy _ matching

Searching for `_` used SQL LIKE wildcards, matching unrelated commands
with multi-byte characters and producing invalid byte match indices that
could panic when rendering results.

Escape `%` and `_` in LIKE patterns and compute highlight indices at
Unicode character boundaries.

Fixes cantino#441

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

Panic when search starts with underscore

1 participant