Skip to main content
Deno 2 is finally here ๐ŸŽ‰๏ธ
Learn more
Module

x/denops_std/helper/mod.ts>ensureSilent

๐Ÿ“š Standard module for denops.vim
Go to Latest
function ensureSilent
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");
  });
}

Parameters

denops: Denops
silent: Silent
executor: () => T

Returns

Promise<T>