Skip to content

Commit 672c011

Browse files
committed
feat: add experimental force recache feature
1 parent f3d4aa7 commit 672c011

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

denops/fall/main/picker.ts

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,39 @@ export const main: Entrypoint = (denops) => {
6969
assert(options, isOptions);
7070
return await startPicker(denops, args, screen, params, options);
7171
},
72-
"picker:reload": async () => {
72+
"picker:reload": async (recache) => {
7373
initialized = undefined;
74-
await init(denops, `#${performance.now()}`);
74+
assert(recache, as.Optional(is.Boolean));
75+
await init(denops, true, recache);
7576
},
7677
};
7778
};
7879

79-
async function init(denops: Denops, suffix?: string): Promise<void> {
80+
async function init(
81+
denops: Denops,
82+
reload?: boolean,
83+
recache?: boolean,
84+
): Promise<void> {
8085
if (initialized) {
8186
return initialized;
8287
}
8388
const path = await denops.eval("expand(g:fall_config_path)") as string;
89+
if (recache) {
90+
const cmd = new Deno.Command(Deno.execPath(), {
91+
args: ["cache", "--reload", "--allow-import", path],
92+
stdin: "null",
93+
stdout: "piped",
94+
stderr: "piped",
95+
});
96+
const { success, stderr, stdout } = await cmd.output();
97+
const decoder = new TextDecoder();
98+
if (success) {
99+
console.log(`Cache reload succeeded: ${path}\n${decoder.decode(stdout)}`);
100+
} else {
101+
console.error(`Cache reload failed: ${path}\n${decoder.decode(stderr)}`);
102+
}
103+
}
104+
const suffix = reload ? `#${performance.now()}` : undefined;
84105
return (initialized = loadUserConfig(denops, path, { suffix }));
85106
}
86107

0 commit comments

Comments
 (0)