File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,10 @@ export type ReadOptions = {
58
58
59
59
/**
60
60
* 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.
61
65
*/
62
66
export async function read (
63
67
denops : Denops ,
Original file line number Diff line number Diff line change
1
+ import { Denops } from "../deps.ts" ;
1
2
import { assertEquals , assertThrowsAsync , test } from "../deps_test.ts" ;
2
3
import { Mapping , Mode } from "./types.ts" ;
3
4
import * as mapping from "./mod.ts" ;
@@ -69,6 +70,10 @@ test({
69
70
mode : "all" ,
70
71
name : `map() registers mapping (script)` ,
71
72
fn : async ( denops ) => {
73
+ if ( ! await isScriptSupported ( denops ) ) {
74
+ console . warn ( "Skip" ) ;
75
+ return ;
76
+ }
72
77
await mapping . map ( denops , "<Plug>(test-denops-std)" , "Hello" , {
73
78
script : true ,
74
79
} ) ;
@@ -276,6 +281,10 @@ test({
276
281
mode : "all" ,
277
282
name : `read() returns mapping (script)` ,
278
283
fn : async ( denops ) => {
284
+ if ( ! await isScriptSupported ( denops ) ) {
285
+ console . warn ( "Skip" ) ;
286
+ return ;
287
+ }
279
288
await denops . cmd ( `map <script> <Plug>(test-denops-std) Hello` ) ;
280
289
assertEquals (
281
290
{
@@ -398,3 +407,11 @@ for (const mode of modes) {
398
407
} ,
399
408
} ) ;
400
409
}
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
+ }
You can’t perform that action at this time.
0 commit comments