Skip to content

Commit d381b95

Browse files
committed
Add initialIndex to processors to specify initial extension
1 parent d62aa59 commit d381b95

4 files changed

Lines changed: 30 additions & 7 deletions

File tree

denops/fall/processor/match.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const CHUNK_SIZE = 1000;
1414
const CHUNK_INTERVAL = 100;
1515

1616
export type MatchProcessorOptions = {
17+
initialIndex?: number;
1718
interval?: number;
1819
threshold?: number;
1920
chunkSize?: number;
@@ -37,7 +38,9 @@ export class MatchProcessor<T extends Detail> implements Disposable {
3738
matchers: readonly [Matcher<T>, ...Matcher<T>[]],
3839
options: MatchProcessorOptions = {},
3940
) {
40-
this.matchers = new ItemBelt(matchers);
41+
this.matchers = new ItemBelt(matchers, {
42+
index: options.initialIndex,
43+
});
4144
this.#interval = options.interval ?? INTERVAL;
4245
this.#threshold = options.threshold ?? THRESHOLD;
4346
this.#chunkSize = options.chunkSize ?? CHUNK_SIZE;

denops/fall/processor/preview.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,24 @@ import type {
88
import { ItemBelt } from "../lib/item_belt.ts";
99
import { dispatch } from "../event.ts";
1010

11+
export type PreviewProcessorOptions = {
12+
initialIndex?: number;
13+
};
14+
1115
export class PreviewProcessor<T extends Detail> implements Disposable {
1216
readonly #controller: AbortController = new AbortController();
1317
readonly previewers: ItemBelt<Previewer<T>>;
1418
#processing?: Promise<void>;
1519
#reserved?: () => void;
1620
#item: PreviewItem | undefined = undefined;
1721

18-
constructor(previewers: readonly Previewer<T>[]) {
19-
this.previewers = new ItemBelt(previewers);
22+
constructor(
23+
previewers: readonly Previewer<T>[],
24+
options: PreviewProcessorOptions = {},
25+
) {
26+
this.previewers = new ItemBelt(previewers, {
27+
index: options.initialIndex,
28+
});
2029
}
2130

2231
get #previewer(): Previewer<T> | undefined {

denops/fall/processor/render.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const HEIGHT = 10;
1414
const SCROLL_OFFSET = 2;
1515

1616
export type RenderProcessorOptions = {
17+
initialIndex?: number;
1718
height?: number;
1819
scrollOffset?: number;
1920
};
@@ -34,7 +35,9 @@ export class RenderProcessor<T extends Detail> implements Disposable {
3435
renderers: readonly Renderer<T>[],
3536
options: RenderProcessorOptions = {},
3637
) {
37-
this.renderers = new ItemBelt(renderers);
38+
this.renderers = new ItemBelt(renderers, {
39+
index: options.initialIndex,
40+
});
3841
this.#height = options.height ?? HEIGHT;
3942
this.#scrollOffset = options.scrollOffset ?? SCROLL_OFFSET;
4043
}

denops/fall/processor/sort.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,23 @@ import type { Sorter } from "jsr:@vim-fall/core@^0.3.0/sorter";
55
import { ItemBelt } from "../lib/item_belt.ts";
66
import { dispatch } from "../event.ts";
77

8+
export type SortProcessorOptions = {
9+
initialIndex?: number;
10+
};
11+
812
export class SortProcessor<T extends Detail> implements Disposable {
913
readonly #controller: AbortController = new AbortController();
1014
readonly sorters: ItemBelt<Sorter<T>>;
1115
#processing?: Promise<void>;
1216
#reserved?: () => void;
1317
#items: IdItem<T>[] = [];
14-
15-
constructor(sorters: readonly Sorter<T>[]) {
16-
this.sorters = new ItemBelt(sorters);
18+
constructor(
19+
sorters: readonly Sorter<T>[],
20+
options: SortProcessorOptions = {},
21+
) {
22+
this.sorters = new ItemBelt(sorters, {
23+
index: options.initialIndex,
24+
});
1725
}
1826

1927
get #sorter(): Sorter<T> | undefined {

0 commit comments

Comments
 (0)