import { ensureSilent } from "https://deno.land/x/denops_std@v4.1.3/helper/mod.ts";
Ensure global silent status during given function
To control silent
and silent!
messages while executing a particular
function, use this function as follows
import { Denops } from "../mod.ts";
import { echo, echoerr, ensureSilent } from "../helper/mod.ts";
export async function main(denops: Denops): Promise<void> {
// Because silent is "silent!", `echo` and `echoerr` doesn't show messages.
await ensureSilent(denops, "silent!", async () => {
await echo(denops, "Hello\nWorld!");
await echoerr(denops, "This is error message");
});
// Because silent is "silent", `echo` doesn't show messages.
await ensureSilent(denops, "silent", async () => {
await echo(denops, "Hello\nWorld!");
await echoerr(denops, "This is error message");
});
// Because silent is "", both shows messages.
await ensureSilent(denops, "", async () => {
await echo(denops, "Hello\nWorld!");
await echoerr(denops, "This is error message");
});
}