File tree Expand file tree Collapse file tree 1 file changed +26
-3
lines changed
extensions/ql-vscode/src/pure Expand file tree Collapse file tree 1 file changed +26
-3
lines changed Original file line number Diff line number Diff line change 33 RepositoryWithMetadata ,
44} from "../variant-analysis/shared/repository" ;
55import { parseDate } from "./date" ;
6+ import { assertNever } from "./helpers-pure" ;
67
78export enum FilterKey {
89 All = "all" ,
@@ -40,9 +41,31 @@ export function matchesFilter(
4041 return true ;
4142 }
4243
43- return item . repository . fullName
44- . toLowerCase ( )
45- . includes ( filterSortState . searchValue . toLowerCase ( ) ) ;
44+ return (
45+ matchesSearch ( item . repository , filterSortState . searchValue ) &&
46+ matchesFilterKey ( item . resultCount , filterSortState . filterKey )
47+ ) ;
48+ }
49+
50+ function matchesSearch (
51+ repository : SortableRepository ,
52+ searchValue : string ,
53+ ) : boolean {
54+ return repository . fullName . toLowerCase ( ) . includes ( searchValue . toLowerCase ( ) ) ;
55+ }
56+
57+ function matchesFilterKey (
58+ resultCount : number | undefined ,
59+ filterKey : FilterKey ,
60+ ) : boolean {
61+ switch ( filterKey ) {
62+ case FilterKey . All :
63+ return true ;
64+ case FilterKey . WithResults :
65+ return resultCount !== undefined && resultCount > 0 ;
66+ default :
67+ assertNever ( filterKey ) ;
68+ }
4669}
4770
4871type SortableRepository = Pick < Repository , "fullName" > &
You can’t perform that action at this time.
0 commit comments