@@ -19,7 +19,7 @@ export type MatchProcessorOptions = {
1919} ;
2020
2121export class MatchProcessor < T extends Detail > {
22- #filter : Matcher < T > ;
22+ #matchers : Matcher < T > [ ] ;
2323 #interval: number ;
2424 #threshold: number ;
2525 #chunkSize: number ;
@@ -28,21 +28,43 @@ export class MatchProcessor<T extends Detail> {
2828 #reserved?: ( ) => void ;
2929 #paused?: PromiseWithResolvers < void > ;
3030 #items: IdItem < T > [ ] = [ ] ;
31+ #matcherIndex = 0 ;
3132
3233 constructor (
33- filter : Matcher < T > ,
34+ filters : Matcher < T > [ ] ,
3435 options : MatchProcessorOptions = { } ,
3536 ) {
36- this . #filter = filter ;
37+ this . #matchers = filters ;
3738 this . #interval = options . interval ?? INTERVAL ;
3839 this . #threshold = options . threshold ?? THRESHOLD ;
3940 this . #chunkSize = options . chunkSize ?? CHUNK_SIZE ;
4041 }
4142
43+ get #matcher( ) : Matcher < T > {
44+ return this . #matchers[ this . #matcherIndex] ;
45+ }
46+
4247 get items ( ) : IdItem < T > [ ] {
4348 return this . #items;
4449 }
4550
51+ get matcherCount ( ) : number {
52+ return this . #matchers. length ;
53+ }
54+
55+ get matcherIndex ( ) : number {
56+ return this . #matcherIndex;
57+ }
58+
59+ set matcherIndex ( index : number | "$" ) {
60+ if ( index === "$" || index >= this . #matchers. length ) {
61+ index = this . #matchers. length - 1 ;
62+ } else if ( index < 0 ) {
63+ index = 0 ;
64+ }
65+ this . #matcherIndex = index ;
66+ }
67+
4668 start (
4769 denops : Denops ,
4870 { items, query } : MatchParams < T > ,
@@ -64,7 +86,7 @@ export class MatchProcessor<T extends Detail> {
6486 const iter = take (
6587 query === ""
6688 ? toAsyncIterable ( items )
67- : this . #filter . match ( denops , { items, query } , { signal } ) ,
89+ : this . #matcher . match ( denops , { items, query } , { signal } ) ,
6890 this . #threshold,
6991 ) ;
7092 // Gradually update items when `items` is empty to improve latency
0 commit comments