16
16
helper . define (
17
17
"CmdlineEnter" ,
18
18
"*" ,
19
- `call feedkeys("Hello world!\\<CR>", "t ")` ,
19
+ `call feedkeys("Hello world!\\<CR>", "it ")` ,
20
20
) ;
21
21
} ) ;
22
22
const result = await input ( denops ) ;
28
28
fn : async ( ) => {
29
29
await autocmd . group ( denops , "denops_std_helper_input" , ( helper ) => {
30
30
helper . remove ( "*" ) ;
31
- helper . define ( "CmdlineEnter" , "*" , `call feedkeys("\\<CR>", "t ")` ) ;
31
+ helper . define ( "CmdlineEnter" , "*" , `call feedkeys("\\<CR>", "it ")` ) ;
32
32
} ) ;
33
33
const result = await input ( denops , {
34
34
text : "Hello world!" ,
44
44
helper . define (
45
45
"CmdlineEnter" ,
46
46
"*" ,
47
- `call feedkeys("\\<Tab>\\<CR>", "t ")` ,
47
+ `call feedkeys("\\<Tab>\\<CR>", "it ")` ,
48
48
) ;
49
49
} ) ;
50
50
const result = await input ( denops , {
61
61
helper . define (
62
62
"CmdlineEnter" ,
63
63
"*" ,
64
- `call feedkeys("\\<Tab>\\<CR>", "t ")` ,
64
+ `call feedkeys("\\<Tab>\\<CR>", "it ")` ,
65
65
) ;
66
66
} ) ;
67
67
const result = await input ( denops , {
88
88
helper . define (
89
89
"CmdlineEnter" ,
90
90
"*" ,
91
- `call feedkeys("\\<Tab>\\<CR>", "t ")` ,
91
+ `call feedkeys("\\<Tab>\\<CR>", "it ")` ,
92
92
) ;
93
93
} ) ;
94
94
const result = await input ( denops , {
@@ -105,7 +105,7 @@ test({
105
105
helper . define (
106
106
"CmdlineEnter" ,
107
107
"*" ,
108
- `call feedkeys("\\<Tab>\\<CR>", "t ")` ,
108
+ `call feedkeys("\\<Tab>\\<CR>", "it ")` ,
109
109
) ;
110
110
} ) ;
111
111
const result = await input ( denops , {
@@ -127,41 +127,113 @@ test({
127
127
) ;
128
128
} ,
129
129
} ) ;
130
- } ,
131
- } ) ;
132
-
133
- test ( {
134
- // XXX: This test does not work properly on Vim
135
- mode : "nvim" ,
136
- name : "returns `null` when <Esc> is pressed" ,
137
- fn : async ( denops ) => {
138
- await autocmd . group ( denops , "denops_std_helper_input" , ( helper ) => {
139
- helper . remove ( "*" ) ;
140
- helper . define (
141
- "CmdlineEnter" ,
142
- "*" ,
143
- `call timer_start(0, { -> feedkeys("Hello world!\\<Esc>", "t") })` ,
144
- ) ;
130
+ await t . step ( {
131
+ name : "returns `null` when <Esc> is pressed" ,
132
+ fn : async ( ) => {
133
+ await autocmd . group ( denops , "denops_std_helper_input" , ( helper ) => {
134
+ helper . remove ( "*" ) ;
135
+ helper . define (
136
+ "CmdlineEnter" ,
137
+ "*" ,
138
+ `call feedkeys("Hello world!\\<Esc>", "it")` ,
139
+ ) ;
140
+ } ) ;
141
+ const result = await input ( denops ) ;
142
+ assertEquals ( result , null ) ;
143
+ } ,
145
144
} ) ;
146
- const result = await input ( denops ) ;
147
- assertEquals ( result , null ) ;
148
- } ,
149
- } ) ;
150
-
151
- test ( {
152
- // XXX: This test does not work properly on Vim
153
- mode : "nvim" ,
154
- name : "returns `null` when <C-c> is pressed" ,
155
- fn : async ( denops ) => {
156
- await autocmd . group ( denops , "denops_std_helper_input" , ( helper ) => {
157
- helper . remove ( "*" ) ;
158
- helper . define (
159
- "CmdlineEnter" ,
160
- "*" ,
161
- `call feedkeys("Hello world!\\<C-c>", "t")` ,
162
- ) ;
145
+ await t . step ( {
146
+ name : "returns `null` when <C-c> is pressed" ,
147
+ fn : async ( ) => {
148
+ await autocmd . group ( denops , "denops_std_helper_input" , ( helper ) => {
149
+ helper . remove ( "*" ) ;
150
+ helper . define (
151
+ "CmdlineEnter" ,
152
+ "*" ,
153
+ `call feedkeys("Hello world!\\<C-c>", "it")` ,
154
+ ) ;
155
+ } ) ;
156
+ const result = await input ( denops ) ;
157
+ assertEquals ( result , null ) ;
158
+ } ,
159
+ } ) ;
160
+ await t . step ( {
161
+ name : "should have global mapping restored" ,
162
+ fn : async ( ) => {
163
+ await denops . cmd ( "cnoremap <Esc> foo" ) ;
164
+ await denops . cmd ( "cmap <silent> <C-c> bar" ) ;
165
+ const globalEsc = await denops . call ( "maparg" , "<Esc>" , "c" , 0 , 1 ) ;
166
+ const globalInt = await denops . call ( "maparg" , "<C-c>" , "c" , 0 , 1 ) ;
167
+ try {
168
+ await autocmd . group ( denops , "denops_std_helper_input" , ( helper ) => {
169
+ helper . remove ( "*" ) ;
170
+ helper . define (
171
+ "CmdlineEnter" ,
172
+ "*" ,
173
+ `call feedkeys("Hello world!\\<CR>", "it")` ,
174
+ ) ;
175
+ } ) ;
176
+ await input ( denops ) ;
177
+ assertEquals (
178
+ await denops . call ( "maparg" , "<Esc>" , "c" , 0 , 1 ) ,
179
+ globalEsc ,
180
+ ) ;
181
+ assertEquals (
182
+ await denops . call ( "maparg" , "<C-c>" , "c" , 0 , 1 ) ,
183
+ globalInt ,
184
+ ) ;
185
+ } finally {
186
+ await denops . cmd ( "silent! cunmap <Esc>" ) ;
187
+ await denops . cmd ( "silent! cunmap <C-c>" ) ;
188
+ }
189
+ } ,
190
+ } ) ;
191
+ await t . step ( {
192
+ name : "should have buffer local mapping restored" ,
193
+ fn : async ( ) => {
194
+ await denops . cmd ( "cnoremap <Esc> foo" ) ;
195
+ await denops . cmd ( "cmap <silent> <C-c> bar" ) ;
196
+ const globalEsc = await denops . call ( "maparg" , "<Esc>" , "c" , 0 , 1 ) ;
197
+ const globalInt = await denops . call ( "maparg" , "<C-c>" , "c" , 0 , 1 ) ;
198
+ await denops . cmd ( "cnoremap <expr><buffer> <Esc> eval('')" ) ;
199
+ await denops . cmd ( "cnoremap <nowait><buffer> <C-c> baz" ) ;
200
+ const bufferEsc = await denops . call ( "maparg" , "<Esc>" , "c" , 0 , 1 ) ;
201
+ const bufferInt = await denops . call ( "maparg" , "<C-c>" , "c" , 0 , 1 ) ;
202
+ try {
203
+ await autocmd . group ( denops , "denops_std_helper_input" , ( helper ) => {
204
+ helper . remove ( "*" ) ;
205
+ helper . define (
206
+ "CmdlineEnter" ,
207
+ "*" ,
208
+ `call feedkeys("Hello world!\\<CR>", "it")` ,
209
+ ) ;
210
+ } ) ;
211
+ await input ( denops ) ;
212
+ assertEquals (
213
+ await denops . call ( "maparg" , "<Esc>" , "c" , 0 , 1 ) ,
214
+ bufferEsc ,
215
+ ) ;
216
+ assertEquals (
217
+ await denops . call ( "maparg" , "<C-c>" , "c" , 0 , 1 ) ,
218
+ bufferInt ,
219
+ ) ;
220
+ await denops . cmd ( "cunmap <buffer> <Esc>" ) ;
221
+ await denops . cmd ( "cunmap <buffer> <C-c>" ) ;
222
+ assertEquals (
223
+ await denops . call ( "maparg" , "<Esc>" , "c" , 0 , 1 ) ,
224
+ globalEsc ,
225
+ ) ;
226
+ assertEquals (
227
+ await denops . call ( "maparg" , "<C-c>" , "c" , 0 , 1 ) ,
228
+ globalInt ,
229
+ ) ;
230
+ } finally {
231
+ await denops . cmd ( "silent! cunmap <buffer> <Esc>" ) ;
232
+ await denops . cmd ( "silent! cunmap <buffer> <C-c>" ) ;
233
+ await denops . cmd ( "silent! cunmap <Esc>" ) ;
234
+ await denops . cmd ( "silent! cunmap <C-c>" ) ;
235
+ }
236
+ } ,
163
237
} ) ;
164
- const result = await input ( denops ) ;
165
- assertEquals ( result , null ) ;
166
238
} ,
167
239
} ) ;
0 commit comments