Repository navigation
fix(staged): match multi-word search queries as AND of terms - #1010
Merged
Merged
Conversation
Searching "one three" did not find a project named "one two three": searchProjects (and the sidebar's searchRepos, All repos, the branch/note project pickers, the hashtag and branch dropdowns and the GitHub repo picker) matched the whole trimmed query as one contiguous, case-folded substring, so a multi-word query only matched that exact phrase. Add shared/textSearch.ts (queryTerms / matchesAllTerms / matchesQuery): the query is split on whitespace and a candidate matches when every term is a case-insensitive substring of at least one of its searchable fields, in any order and not necessarily adjacent. Single-term queries behave as before, blank queries still return the input unchanged, and result order is preserved. The repo picker's matchesRepoSearch already tokenized this way and is unchanged. Tests cover "one three" / "three one" matching "one two three", "one four" not matching, single terms, case-insensitivity, blank queries and terms landing in different fields. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Matt Toohey <contact@matttoohey.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
… span fields Follow-up to the multi-word search change (1d6305a), addressing its review findings: - filterMoveTargets (MoveBranchDialog's project picker) required every term to land in the project name or every term to match one attached repo, so "alpha widgets" found nothing for a project named "Alpha" with acme/widgets attached, even though the sidebar and All repos searches let terms straddle fields. Export searchTerms from shared/repoSearch and pass the name plus every attached repo's search terms into a single matchesAllTerms call. Test added for the mixed-field case. - matchesRepoSearch carried its own copy of the query tokenization and every/some loop; it is now matchesAllTerms(queryTerms(query), ...searchTerms(...)), so there is one definition of how a query is split. Behaviour is unchanged, including blank query → true. - matchesQuery had no production callers (every call site pre-splits with queryTerms once per keystroke); removed along with its tests, which now exercise matchesAllTerms directly. - sidebarSearch's normalizeQuery only served as a blank check after the previous change; its two uses are queryTerms(query).length === 0 and the export and its test are gone. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Matt Toohey <contact@matttoohey.com>
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
Searching
one threedid not find a project namedone two three. Every client-side search field (landing grid/sidebarsearchProjects, the sidebar'ssearchRepos, All repos, the branch/note project pickers, the hashtag and branch dropdowns, and the GitHub repo picker) matched the whole trimmed query as a single contiguous, case-folded substring, so a multi-word query only matched that exact phrase.src/lib/shared/textSearch.tswithqueryTerms/matchesAllTerms/matchesQuery: the query is split on whitespace and a candidate matches when every term is a case-insensitive substring of at least one of its searchable fields, in any order and not necessarily adjacent or in the same field.projectSearch,sidebarSearch,moveBranchTarget,BranchPicker,RepoSearchInput,ReposListViewandHashtagInputto the shared helpers.matchesRepoSearchalready tokenized this way and is unchanged.Tests
textSearch.test.tscoversone three/three onematchingone two three,one fournot matching, single terms, case-insensitivity, blank queries and terms landing in different fields.projectSearch,sidebarSearchandmoveBranchTargettests with multi-word cases.staged-ci,crates-*,differ-ci) passed on push.🤖 Generated with Claude Code