Skip to content

Commit a4885d6

Browse files
committed
🐛 Fix Failed to parse a mapping record issue
Close #152
1 parent dd365e5 commit a4885d6

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

denops_std/mapping/parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Mapping, Mode } from "./types.ts";
44
* Parse record displayed by Vim's `map` command and return a `Mapping` instance.
55
*/
66
export function parse(record: string): Mapping {
7-
const m = record.match(/^(.)\s+(\S+)\s+(.*)$/);
7+
const m = record.match(/^(...)(\S+)\s+(.*)$/);
88
if (!m) {
99
throw new Error(`Failed to parse a mapping record '${record}'`);
1010
}

denops_std/mapping/parser_test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,22 @@ const testcases: [string, Mapping][] = [
7474
buffer: false,
7575
},
7676
],
77+
["ov # <Plug>(asterisk-z#)zv", {
78+
mode: "ov",
79+
lhs: "#",
80+
rhs: "<Plug>(asterisk-z#)zv",
81+
noremap: false,
82+
script: false,
83+
buffer: false,
84+
}],
85+
["nosa * b", {
86+
mode: "nos",
87+
lhs: "a",
88+
rhs: "b",
89+
noremap: true,
90+
script: false,
91+
buffer: false,
92+
}],
7793
];
7894
for (const [record, expected] of testcases) {
7995
Deno.test(`parse() parses '${record}' and return a Mapping instance`, () => {

denops_std/mapping/types.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,17 @@ export type Mode =
88
| "s" // Select
99
| "o" // Operator-pending
1010
| "t" // Terminal-Job
11-
| "l"; // ":lmap" mappings for Insert, Command-line and Lang-Arg
11+
| "l" // ":lmap" mappings for Insert, Command-line and Lang-Arg
12+
// See https://github.com/vim-denops/deno-denops-std/issues/152 for detail
13+
| "ov"
14+
| "nv"
15+
| "no"
16+
| "os"
17+
| "ns"
18+
| "ox"
19+
| "nx"
20+
| "nox"
21+
| "nos";
1222

1323
export type Mapping = {
1424
// Modes for which the mapping is defined

0 commit comments

Comments
 (0)