Skip to content

Commit f2731d8

Browse files
committed
🌿 Skip tests for <script> mapping in old Vim/Neovim
1 parent 1015818 commit f2731d8

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

denops_std/mapping/mod.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ export type ReadOptions = {
5858

5959
/**
6060
* Read a mapping and return a `Mapping` instance.
61+
*
62+
* Note that prior to Vim 8.2.0491 or Neovim 0.5.0, `script` is
63+
* not detectable by `maparg` function internally used in this
64+
* function.
6165
*/
6266
export async function read(
6367
denops: Denops,

denops_std/mapping/mod_test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Denops } from "../deps.ts";
12
import { assertEquals, assertThrowsAsync, test } from "../deps_test.ts";
23
import { Mapping, Mode } from "./types.ts";
34
import * as mapping from "./mod.ts";
@@ -69,6 +70,10 @@ test({
6970
mode: "all",
7071
name: `map() registers mapping (script)`,
7172
fn: async (denops) => {
73+
if (!await isScriptSupported(denops)) {
74+
console.warn("Skip");
75+
return;
76+
}
7277
await mapping.map(denops, "<Plug>(test-denops-std)", "Hello", {
7378
script: true,
7479
});
@@ -276,6 +281,10 @@ test({
276281
mode: "all",
277282
name: `read() returns mapping (script)`,
278283
fn: async (denops) => {
284+
if (!await isScriptSupported(denops)) {
285+
console.warn("Skip");
286+
return;
287+
}
279288
await denops.cmd(`map <script> <Plug>(test-denops-std) Hello`);
280289
assertEquals(
281290
{
@@ -398,3 +407,11 @@ for (const mode of modes) {
398407
},
399408
});
400409
}
410+
411+
async function isScriptSupported(denops: Denops): Promise<boolean> {
412+
if (denops.meta.host === "vim") {
413+
return !!await denops.call("has", "patch-8.2.0491");
414+
} else {
415+
return !!await denops.call("has", "nvim-0.5.0");
416+
}
417+
}

0 commit comments

Comments
 (0)