Skip to content

Conversation

@echobt
Copy link
Contributor

@echobt echobt commented Jan 20, 2026

Description

This PR fixes a bug where the path prefix search in search_similar uses a SQL LIKE pattern without directory boundaries. This caused partial matches where searching for a directory (e.g., /home/user/proj) would also match sibling directories starting with the same prefix (e.g., /home/user/project).

Fix

The fix ensures that the LIKE pattern includes a trailing directory separator if one is not already present.

  • Before: path LIKE '/home/user/proj%' (matches .../project)
  • After: path LIKE '/home/user/proj/%' (matches only inside proj)

Verification

Added a regression test test_path_prefix_search_bug_reproduction in src/core/db.rs which asserts that searching for a prefix does not return files from sibling directories sharing that prefix.
Ran cargo test and verified that the new test passes and no existing tests are broken.

Added a trailing slash to the SQL LIKE pattern to prevent partial directory matching (e.g., 'proj' matching 'project'). Added a regression test.
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.

2 participants