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";
77import * as lambda from "../lambda/mod.ts" ;
88import { execute } from "./execute.ts" ;
99
10- const cacheKey = "denops_std/helper/input@2 " ;
10+ const cacheKey = "denops_std/helper/input@3 " ;
1111
1212async function ensurePrerequisites ( denops : Denops ) : Promise < string > {
1313 if ( typeof denops . context [ cacheKey ] === "string" ) {
@@ -71,8 +71,8 @@ async function ensurePrerequisites(denops: Denops): Promise<string> {
7171 function! s:input_${ suffix } (prompt, text, completion) abort
7272 let originalEsc = maparg('<Esc>', 'c', 0, 1)
7373 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 } )
7676 try
7777 let result = a:completion is# v:null
7878 \\ ? input(a:prompt, a:text)
Original file line number Diff line number Diff line change @@ -157,6 +157,36 @@ test({
157157 assertEquals ( result , null ) ;
158158 } ,
159159 } ) ;
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+ } ) ;
160190 await t . step ( {
161191 name : "should have global mapping restored" ,
162192 fn : async ( ) => {
You can’t perform that action at this time.
0 commit comments