Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions helper/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as fn from "../function/mod.ts";
import * as lambda from "../lambda/mod.ts";
import { execute } from "./execute.ts";

const cacheKey = "denops_std/helper/input@2";
const cacheKey = "denops_std/helper/input@3";

async function ensurePrerequisites(denops: Denops): Promise<string> {
if (typeof denops.context[cacheKey] === "string") {
Expand Down Expand Up @@ -71,8 +71,8 @@ async function ensurePrerequisites(denops: Denops): Promise<string> {
function! s:input_${suffix}(prompt, text, completion) abort
let originalEsc = maparg('<Esc>', 'c', 0, 1)
let originalInt = maparg('<C-c>', 'c', 0, 1)
execute printf('cnoremap <nowait><buffer> <Esc> <C-u>%s<CR>', s:escape_token_${suffix})
execute printf('cnoremap <nowait><buffer> <C-c> <C-u>%s<CR>', s:escape_token_${suffix})
execute printf('cnoremap <nowait><buffer> <Esc> <C-e><C-u>%s<CR>', s:escape_token_${suffix})
execute printf('cnoremap <nowait><buffer> <C-c> <C-e><C-u>%s<CR>', s:escape_token_${suffix})
try
let result = a:completion is# v:null
\\ ? input(a:prompt, a:text)
Expand Down
30 changes: 30 additions & 0 deletions helper/input_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,36 @@ test({
assertEquals(result, null);
},
});
await t.step({
name: "returns `null` when <Esc> is pressed outside EOL",
fn: async () => {
await autocmd.group(denops, "denops_std_helper_input", (helper) => {
helper.remove("*");
helper.define(
"CmdlineEnter",
"*",
`call feedkeys("Hello world!\\<Left>\\<Esc>", "it")`,
);
});
const result = await input(denops);
assertEquals(result, null);
},
});
await t.step({
name: "returns `null` when <C-c> is pressed outside EOL",
fn: async () => {
await autocmd.group(denops, "denops_std_helper_input", (helper) => {
helper.remove("*");
helper.define(
"CmdlineEnter",
"*",
`call feedkeys("Hello world!\\<Left>\\<C-c>", "it")`,
);
});
const result = await input(denops);
assertEquals(result, null);
},
});
await t.step({
name: "should have global mapping restored",
fn: async () => {
Expand Down