fix(search): always check parent index regardless of cwd#153
Merged
Conversation
The is_external_project_path gate skipped find_parent_index when the search path was not a subdirectory of cwd. This meant that searching an absolute path from an unrelated working directory (e.g. running `colgrep "query" /path/to/sub/` from ~/.local/share/colgrep/indices) would fail to find the parent index and either build a redundant index or return no results. The local_index_exists check already short-circuits the common case (searching a directly-indexed project root). For subdirectory searches, find_parent_index is both necessary and cheap (one read_dir + one JSON parse per indexed project). Removes is_external_project_path and its Windows-only test as they are now dead code.
Collaborator
|
Amazing MR @vlasky you rock 🤘 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
is_external_project_pathgate that skippedfind_parent_indexwhen the search path was not a subdirectory of cwdlocal_index_existscheck already short-circuits the common case;find_parent_indexis cheap (oneread_dir+ one JSON parse per indexed project)Repro
Expected: uses existing index for
~/projects/myrepoActual (before fix): fails to find the parent index because
/tmpis not an ancestor of the search pathTest plan
cargo build -p colgrepcleancargo clippy -p colgrep -- -D warningscleancargo test -p colgrep --libpasses (662 tests)