@@ -5,6 +5,7 @@ import type { Detail, IdItem } from "jsr:@vim-fall/std@^0.4.0/item";
55import type { Matcher , MatchParams } from "jsr:@vim-fall/std@^0.4.0/matcher" ;
66
77import { Chunker } from "../lib/chunker.ts" ;
8+ import { ItemBelt } from "../lib/item_belt.ts" ;
89import { dispatch } from "../event.ts" ;
910
1011const INTERVAL = 0 ;
@@ -19,7 +20,7 @@ export type MatchProcessorOptions = {
1920} ;
2021
2122export class MatchProcessor < T extends Detail > implements Disposable {
22- readonly #matchers: readonly [ Matcher < T > , ... Matcher < T > [ ] ] ;
23+ readonly #matchers: ItemBelt < Matcher < T > > ;
2324 readonly #interval: number ;
2425 readonly #threshold: number ;
2526 readonly #chunkSize: number ;
@@ -28,42 +29,39 @@ export class MatchProcessor<T extends Detail> implements Disposable {
2829 #processing?: Promise < void > ;
2930 #reserved?: ( ) => void ;
3031 #items: IdItem < T > [ ] = [ ] ;
31- #matcherIndex = 0 ;
3232
3333 constructor (
34- filters : readonly [ Matcher < T > , ...Matcher < T > [ ] ] ,
34+ matchers : readonly [ Matcher < T > , ...Matcher < T > [ ] ] ,
3535 options : MatchProcessorOptions = { } ,
3636 ) {
37- this . #matchers = filters ;
37+ this . #matchers = new ItemBelt ( matchers ) ;
3838 this . #interval = options . interval ?? INTERVAL ;
3939 this . #threshold = options . threshold ?? THRESHOLD ;
4040 this . #chunkSize = options . chunkSize ?? CHUNK_SIZE ;
4141 this . #incremental = options . incremental ?? false ;
4242 }
4343
4444 get #matcher( ) : Matcher < T > {
45- return this . #matchers[ this . #matcherIndex ] ;
45+ return this . #matchers. current ! ;
4646 }
4747
4848 get items ( ) : IdItem < T > [ ] {
4949 return this . #items;
5050 }
5151
5252 get matcherCount ( ) : number {
53- return this . #matchers. length ;
53+ return this . #matchers. count ;
5454 }
5555
5656 get matcherIndex ( ) : number {
57- return this . #matcherIndex ;
57+ return this . #matchers . index ;
5858 }
5959
6060 set matcherIndex ( index : number | "$" ) {
61- if ( index === "$" || index >= this . #matchers. length ) {
62- index = this . #matchers. length - 1 ;
63- } else if ( index < 0 ) {
64- index = 0 ;
61+ if ( index === "$" ) {
62+ index = this . #matchers. count ;
6563 }
66- this . #matcherIndex = index ;
64+ this . #matchers . index = index ;
6765 }
6866
6967 #validateAvailability( ) : void {
0 commit comments