Skip to content

[BUG] Path prefix search uses LIKE without directory boundary, matching unintended directories #113

@Cute0110

Description

@Cute0110

Project

vgrep

Description

The path prefix search uses a SQL LIKE pattern without ensuring directory boundaries, causing unintended matches with similarly-named directories.

Error Observation

Searching with path prefix /home/user/proj also matches /home/user/project, /home/user/proj-backup, etc.

Error Message

Debug Logs

System Information

Version: 0.1.0

## Operating System
  OS: Ubuntu 24.04.3 LTS
  Kernel: 6.8.0-79-generic
  Arch: x86_64

## Hardware
  CPU: AMD Ryzen 9 5950X 16-Core Processor (4 cores)
  RAM: 11 GB

## Build Environment
  Rust: rustc 1.92.0 (ded5c06cf 2025-12-08)
  Target: x86_64

Screenshots

No response

Steps to Reproduce

  1. Index two directories: /home/user/proj and /home/user/project
  2. Search with path prefix /home/user/proj
  3. Observe that results include files from both directories

Code in src/core/db.rs line 162:

let path_prefix_str = path_prefix.to_string_lossy();
let like_pattern = format!("{}%", path_prefix_str);

### Expected Behavior

Should add trailing slash to ensure only files within the exact directory are matched.

### Actual Behavior

Search results include files from sibling directories with similar name prefixes.

### Additional Context

_No response_

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingvalidValid issuevgrep

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions