Skip to content

Commit ef5067f

Browse files
authored
Merge pull request #89 from vim-denops/fix-input
🐛 Do NOT use `once` for completion function of `input`
2 parents 3619d03 + 76a2dfa commit ef5067f

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

denops_std/helper/input.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,23 @@ export async function input(
3434
await helper.load(denops, new URL("./input.vim", import.meta.url));
3535
const completion = options.completion ?? null;
3636
if (completion && typeof completion !== "string") {
37-
const [id] = anonymous.once(denops, async (arglead, cmdline, cursorpos) => {
37+
const [id] = anonymous.add(denops, async (arglead, cmdline, cursorpos) => {
3838
ensureString(arglead);
3939
ensureString(cmdline);
4040
ensureNumber(cursorpos);
4141
return await completion(arglead, cmdline, cursorpos);
4242
});
43-
return await denops.call(
44-
"DenopsStdHelperInput",
45-
options.prompt ?? "",
46-
options.text ?? "",
47-
{ plugin: denops.name, id },
48-
options.inputsave ?? false,
49-
) as Promise<string | null>;
43+
try {
44+
return await denops.call(
45+
"DenopsStdHelperInput",
46+
options.prompt ?? "",
47+
options.text ?? "",
48+
{ plugin: denops.name, id },
49+
options.inputsave ?? false,
50+
) as Promise<string | null>;
51+
} finally {
52+
anonymous.remove(denops, id);
53+
}
5054
}
5155
if (completion && !fn.isValidBuiltinCompletion(completion)) {
5256
if (

0 commit comments

Comments
 (0)