Skip to content

Commit a8daf69

Browse files
committed
🐛 Do NOT rely on autocmd to fix Vim freeze
Close #120 It seems newer Vim supports multiline message from timer so we just simplify implementation of `helper.echo` by using timer to solve #120.
1 parent befc825 commit a8daf69

File tree

3 files changed

+7
-54
lines changed

3 files changed

+7
-54
lines changed

denops_std/helper/README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,9 @@
99
### echo / echoerr
1010

1111
Use `echo()` to show messages on the cmdline area. It is required while Vim
12-
won't show messages reported from channel commands and it won't pause multi-line
13-
messages reported from asynchronous context (e.g. timer or job). It's same for
12+
won't show messages reported from channel commands. It's same for
1413
`denops.cmd('echo "Hello\nWorld!"')` in Neovim.
1514

16-
Note that there is no similar function for `echomsg` while there is no way to
17-
properly show multi-line messages with `echomsg` from asynchronous context.
18-
1915
```typescript
2016
import { Denops } from "https://deno.land/x/denops_std/mod.ts";
2117
import { echo, echoerr } from "https://deno.land/x/denops_std/helper/mod.ts";
@@ -40,7 +36,7 @@ import { friendlyCall } from "https://deno.land/x/denops_std/helper/mod.ts";
4036

4137
export async function main(denops: Denops): Promise<void> {
4238
denops.dispatcher = {
43-
"say": () => {
39+
say: () => {
4440
return friendlyCall(denops, async () => {
4541
// Do whatever you want.
4642
throw new Error("Some error occured");

denops_std/helper/echo.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import { deferred, Denops } from "../deps.ts";
2-
import * as anonymous from "../anonymous/mod.ts";
1+
import { Denops } from "../deps.ts";
32
import { batch } from "../batch/mod.ts";
4-
import { load } from "./load.ts";
53

64
/**
75
* Echo message as like `echo` on Vim script.
@@ -18,7 +16,10 @@ export function echo(denops: Denops, message: string): Promise<void> {
1816
if (denops.meta.mode === "test") {
1917
return Promise.resolve();
2018
} else if (denops.meta.host === "vim") {
21-
return echoVim(denops, message);
19+
return denops.cmd(
20+
"call timer_start(0, { -> execute('redraw | echo message', '') })",
21+
{ message },
22+
);
2223
} else {
2324
return denops.cmd("redraw | echo message", { message });
2425
}
@@ -61,11 +62,3 @@ export async function friendlyCall(
6162
}
6263
}
6364
}
64-
65-
async function echoVim(denops: Denops, message: string): Promise<void> {
66-
await load(denops, new URL("./echo.vim", import.meta.url));
67-
const waiter = deferred<void>();
68-
const id = anonymous.once(denops, () => waiter.resolve())[0];
69-
await denops.call("DenopsStdHelperEcho", message, denops.name, id);
70-
await waiter;
71-
}

denops_std/helper/echo.vim

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)