File tree Expand file tree Collapse file tree 2 files changed +33
-3
lines changed Expand file tree Collapse file tree 2 files changed +33
-3
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import * as fn from "../function/mod.ts";
7
7
import * as lambda from "../lambda/mod.ts" ;
8
8
import { execute } from "./execute.ts" ;
9
9
10
- const cacheKey = "denops_std/helper/input@2 " ;
10
+ const cacheKey = "denops_std/helper/input@3 " ;
11
11
12
12
async function ensurePrerequisites ( denops : Denops ) : Promise < string > {
13
13
if ( typeof denops . context [ cacheKey ] === "string" ) {
@@ -71,8 +71,8 @@ async function ensurePrerequisites(denops: Denops): Promise<string> {
71
71
function! s:input_${ suffix } (prompt, text, completion) abort
72
72
let originalEsc = maparg('<Esc>', 'c', 0, 1)
73
73
let originalInt = maparg('<C-c>', 'c', 0, 1)
74
- execute printf('cnoremap <nowait><buffer> <Esc> <C-u>%s<CR>', s:escape_token_${ suffix } )
75
- execute printf('cnoremap <nowait><buffer> <C-c> <C-u>%s<CR>', s:escape_token_${ suffix } )
74
+ execute printf('cnoremap <nowait><buffer> <Esc> <C-e><C- u>%s<CR>', s:escape_token_${ suffix } )
75
+ execute printf('cnoremap <nowait><buffer> <C-c> <C-e><C- u>%s<CR>', s:escape_token_${ suffix } )
76
76
try
77
77
let result = a:completion is# v:null
78
78
\\ ? input(a:prompt, a:text)
Original file line number Diff line number Diff line change @@ -157,6 +157,36 @@ test({
157
157
assertEquals ( result , null ) ;
158
158
} ,
159
159
} ) ;
160
+ await t . step ( {
161
+ name : "returns `null` when <Esc> is pressed outside EOL" ,
162
+ fn : async ( ) => {
163
+ await autocmd . group ( denops , "denops_std_helper_input" , ( helper ) => {
164
+ helper . remove ( "*" ) ;
165
+ helper . define (
166
+ "CmdlineEnter" ,
167
+ "*" ,
168
+ `call feedkeys("Hello world!\\<Left>\\<Esc>", "it")` ,
169
+ ) ;
170
+ } ) ;
171
+ const result = await input ( denops ) ;
172
+ assertEquals ( result , null ) ;
173
+ } ,
174
+ } ) ;
175
+ await t . step ( {
176
+ name : "returns `null` when <C-c> is pressed outside EOL" ,
177
+ fn : async ( ) => {
178
+ await autocmd . group ( denops , "denops_std_helper_input" , ( helper ) => {
179
+ helper . remove ( "*" ) ;
180
+ helper . define (
181
+ "CmdlineEnter" ,
182
+ "*" ,
183
+ `call feedkeys("Hello world!\\<Left>\\<C-c>", "it")` ,
184
+ ) ;
185
+ } ) ;
186
+ const result = await input ( denops ) ;
187
+ assertEquals ( result , null ) ;
188
+ } ,
189
+ } ) ;
160
190
await t . step ( {
161
191
name : "should have global mapping restored" ,
162
192
fn : async ( ) => {
You can’t perform that action at this time.
0 commit comments