Skip to content

Commit eda984c

Browse files
committed
feat: do NOT dispose extensions
Extensions are instantiated in configuration files thus disposing them in picker means we must re-use disposed extensions in the next picker. That behavior is misleading and should be avoided so we must NOT dispose extension itself.
1 parent f74eddd commit eda984c

File tree

6 files changed

+10
-22
lines changed

6 files changed

+10
-22
lines changed

denops/fall/main/picker.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import type {
1616
ItemPickerParams,
1717
} from "jsr:@vim-fall/std@^0.4.0/config";
1818

19-
import { ensureAsyncDisposable } from "../lib/dispose.ts";
2019
import {
2120
getActionPickerParams,
2221
getGlobalConfig,
@@ -184,7 +183,6 @@ async function startPicker(
184183
if (!action) {
185184
throw new Error(`Action "${actionName}" is not found`);
186185
}
187-
await using _guardAction = ensureAsyncDisposable(action);
188186
const actionParams = {
189187
// for 'submatch' action
190188
_submatchContext: {

denops/fall/processor/collect.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import type { Detail, IdItem } from "jsr:@vim-fall/std@^0.4.0/item";
55
import type { CollectParams, Source } from "jsr:@vim-fall/std@^0.4.0/source";
66

77
import { Chunker } from "../lib/chunker.ts";
8-
import { dispose } from "../lib/dispose.ts";
98
import { dispatch } from "../event.ts";
109

1110
const THRESHOLD = 100000;
@@ -16,7 +15,7 @@ export type CollectProcessorOptions = {
1615
chunkSize?: number;
1716
};
1817

19-
export class CollectProcessor<T extends Detail> implements AsyncDisposable {
18+
export class CollectProcessor<T extends Detail> implements Disposable {
2019
readonly #source: Source<T>;
2120
readonly #threshold: number;
2221
readonly #chunkSize: number;
@@ -110,12 +109,11 @@ export class CollectProcessor<T extends Detail> implements AsyncDisposable {
110109
this.#paused = undefined;
111110
}
112111

113-
async [Symbol.asyncDispose](): Promise<void> {
112+
[Symbol.dispose](): void {
114113
try {
115114
this.#controller.abort(null);
116115
} catch {
117116
// Ignore
118117
}
119-
await dispose(this.#source);
120118
}
121119
}

denops/fall/processor/match.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import type { Detail, IdItem } from "jsr:@vim-fall/std@^0.4.0/item";
55
import type { Matcher, MatchParams } from "jsr:@vim-fall/std@^0.4.0/matcher";
66

77
import { Chunker } from "../lib/chunker.ts";
8-
import { dispose } from "../lib/dispose.ts";
98
import { dispatch } from "../event.ts";
109

1110
const INTERVAL = 0;
@@ -19,7 +18,7 @@ export type MatchProcessorOptions = {
1918
incremental?: boolean;
2019
};
2120

22-
export class MatchProcessor<T extends Detail> implements AsyncDisposable {
21+
export class MatchProcessor<T extends Detail> implements Disposable {
2322
readonly #matchers: readonly [Matcher<T>, ...Matcher<T>[]];
2423
readonly #interval: number;
2524
readonly #threshold: number;
@@ -138,12 +137,11 @@ export class MatchProcessor<T extends Detail> implements AsyncDisposable {
138137
});
139138
}
140139

141-
async [Symbol.asyncDispose]() {
140+
[Symbol.dispose](): void {
142141
try {
143142
this.#controller.abort(null);
144143
} catch {
145144
// Ignore
146145
}
147-
await Promise.all(this.#matchers.map((v) => dispose(v)));
148146
}
149147
}

denops/fall/processor/preview.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ import type {
55
PreviewParams,
66
} from "jsr:@vim-fall/std@^0.4.0/previewer";
77

8-
import { dispose } from "../lib/dispose.ts";
98
import { dispatch } from "../event.ts";
109

11-
export class PreviewProcessor<T extends Detail> implements AsyncDisposable {
10+
export class PreviewProcessor<T extends Detail> implements Disposable {
1211
readonly #previewers: Previewer<T>[];
1312
readonly #controller: AbortController = new AbortController();
1413
#processing?: Promise<void>;
@@ -94,12 +93,11 @@ export class PreviewProcessor<T extends Detail> implements AsyncDisposable {
9493
});
9594
}
9695

97-
async [Symbol.asyncDispose]() {
96+
[Symbol.dispose](): void {
9897
try {
9998
this.#controller.abort(null);
10099
} catch {
101100
// Ignore
102101
}
103-
await Promise.all(this.#previewers.map((v) => dispose(v)));
104102
}
105103
}

denops/fall/processor/render.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import type {
77
import type { Renderer } from "jsr:@vim-fall/std@^0.4.0/renderer";
88

99
import { adjustOffset } from "../lib/adjust_offset.ts";
10-
import { dispose } from "../lib/dispose.ts";
1110
import { dispatch } from "../event.ts";
1211

1312
const HEIGHT = 10;
@@ -18,7 +17,7 @@ export type RenderProcessorOptions = {
1817
scrollOffset?: number;
1918
};
2019

21-
export class RenderProcessor<T extends Detail> implements AsyncDisposable {
20+
export class RenderProcessor<T extends Detail> implements Disposable {
2221
readonly #renderers: Renderer<T>[];
2322
#height: number;
2423
#scrollOffset: number;
@@ -183,12 +182,11 @@ export class RenderProcessor<T extends Detail> implements AsyncDisposable {
183182
});
184183
}
185184

186-
async [Symbol.asyncDispose]() {
185+
[Symbol.dispose](): void {
187186
try {
188187
this.#controller.abort(null);
189188
} catch {
190189
// Ignore
191190
}
192-
await Promise.all(this.#renderers.map((v) => dispose(v)));
193191
}
194192
}

denops/fall/processor/sort.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ import type { Denops } from "jsr:@denops/std@^7.3.2";
22
import type { Detail, IdItem } from "jsr:@vim-fall/std@^0.4.0/item";
33
import type { Sorter } from "jsr:@vim-fall/std@^0.4.0/sorter";
44

5-
import { dispose } from "../lib/dispose.ts";
65
import { dispatch } from "../event.ts";
76

8-
export class SortProcessor<T extends Detail> implements AsyncDisposable {
7+
export class SortProcessor<T extends Detail> implements Disposable {
98
readonly #sorters: Sorter<T>[];
109
readonly #controller: AbortController = new AbortController();
1110
#processing?: Promise<void>;
@@ -87,12 +86,11 @@ export class SortProcessor<T extends Detail> implements AsyncDisposable {
8786
});
8887
}
8988

90-
async [Symbol.asyncDispose]() {
89+
[Symbol.dispose](): void {
9190
try {
9291
this.#controller.abort(null);
9392
} catch {
9493
// Ignore
9594
}
96-
await Promise.all(this.#sorters.map((v) => dispose(v)));
9795
}
9896
}

0 commit comments

Comments
 (0)