Skip to main content
Module

x/denops_std/helper/echo.ts>ensureSilent

📚 Standard module for denops.vim
Go to Latest
function ensureSilent
import { ensureSilent } from "https://deno.land/x/denops_std@v4.1.6/helper/echo.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>