Ensure searches on PRs also includes the branch name

This commit is contained in:
Caleb Owens 2024-02-15 20:44:45 +00:00 committed by Kiril Videlov
parent 4570a82256
commit 8f0c695465
2 changed files with 23 additions and 1 deletions

View File

@ -85,6 +85,19 @@ export class CombinedBranch {
}
}
get searchableIdentifiers() {
const identifiers = [];
if (this.vbranch) identifiers.push(this.vbranch.name);
if (this.pr) {
identifiers.push(this.pr.title);
identifiers.push(this.pr.targetBranch);
}
if (this.remoteBranch) identifiers.push(this.remoteBranch.displayName);
return identifiers.map((identifier) => identifier.toLowerCase());
}
currentState(): BranchState | undefined {
if (this.vbranch) return BranchState.VirtualBranch;
if (this.pr) return BranchState.PR;

View File

@ -91,7 +91,16 @@
function filterByText(branches: CombinedBranch[], search: string | undefined) {
if (search == undefined) return branches;
return branches.filter((b) => b.displayName.includes(search));
return branches.filter((b) => searchMatchesAnIdentifier(search, b.searchableIdentifiers));
}
function searchMatchesAnIdentifier(search: string, identifiers: string[]) {
for (const identifier of identifiers) {
if (identifier.includes(search.toLowerCase())) return true;
}
return false;
}
function filterInactive(branches: CombinedBranch[]) {