Skip to content

Commit c7d76f1

Browse files
authored
Merge pull request #23 from vim-denops/improve-verbose-output
👍 Improve verbose output and add test for multiline output
2 parents 321e907 + 46582ad commit c7d76f1

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

runner.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ function buildArgs(conf: Config, mode: RunMode): [string, string[]] {
119119
"-V1", // Verbose level 1 (Echo messages to stderr)
120120
"-c",
121121
"visual", // Go to Normal mode
122+
"-c",
123+
"set columns=9999", // Avoid unwilling output newline
122124
],
123125
];
124126
case "nvim":
@@ -129,6 +131,8 @@ function buildArgs(conf: Config, mode: RunMode): [string, string[]] {
129131
"--headless",
130132
"-n", // Disable swap file
131133
"-V1", // Verbose level 1 (Echo messages to stderr)
134+
"-c",
135+
"set columns=9999", // Avoid unwilling output newline
132136
],
133137
];
134138
default:

with_test.ts

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
assert,
3+
assertArrayIncludes,
34
assertEquals,
45
assertFalse,
56
assertRejects,
@@ -27,12 +28,33 @@ Deno.test("test(mode:nvim) start nvim to test denops features", async () => {
2728
for (const mode of ["vim", "nvim"] as const) {
2829
Deno.test(`test(mode:${mode}) outputs ${mode} messages if 'verbose' option is true`, async () => {
2930
using s = stub(console, "error");
30-
await withDenops("vim", async (denops: Denops) => {
31-
await denops.cmd("echomsg 'foobar'");
31+
await withDenops(mode, async (denops: Denops) => {
32+
await denops.cmd("echomsg 'Hello. Hello. Hello. Hello. Hello. Hello.'");
33+
await denops.cmd("echomsg 'World. World. World. World. World. World.'");
3234
}, { verbose: true });
33-
// NOTE: Maybe some other values are included, so find target with `Array.some`.
34-
// NOTE: Maybe "\r" or "\n" is prepend or postpend, so use `String.trim`.
35-
assert(s.calls.some((c) => c.args[0].trim() === "foobar"));
35+
const rawOutput = s.calls.map((c) => c.args[0]);
36+
const normOutput = rawOutput.join("").split("\r\n").map((v) => v.trim());
37+
//
38+
// NOTE:
39+
//
40+
// It appears that Neovim doesn't insert any delimiters between consecutive 'echomsg' calls,
41+
// and the chunk lengths are unstable as a result.
42+
// This inconsistency causes issues with Neovim's verbose output, but we couldn't find a workaround
43+
// to resolve this problem.
44+
// Interestingly, this issue only arises when producing verbose output using denops.vim, making it
45+
// difficult for us to reproduce the phenomenon and report it to Neovim's issue tracker.
46+
// While verbose output is essential for debugging, we're forced to accept our current situation.
47+
//
48+
if (mode === "vim") {
49+
assertArrayIncludes(normOutput, [
50+
"Hello. Hello. Hello. Hello. Hello. Hello.",
51+
"World. World. World. World. World. World.",
52+
]);
53+
} else {
54+
assertArrayIncludes(normOutput, [
55+
"Hello. Hello. Hello. Hello. Hello. Hello.World. World. World. World. World. World.",
56+
]);
57+
}
3658
});
3759

3860
Deno.test(`test(mode:${mode}) should be able to call Denops#redraw()`, async () => {

0 commit comments

Comments
 (0)