From 99f2f055c3c8ba8fe18ab9dda34389ba9334e359 Mon Sep 17 00:00:00 2001 From: kuuote Date: Sat, 30 Dec 2023 13:27:14 +0900 Subject: [PATCH 1/2] fix: can't cancel select candidates Fix #173 --- denops/skkeleton/function/henkan.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/denops/skkeleton/function/henkan.ts b/denops/skkeleton/function/henkan.ts index 6036b503..f1464f75 100644 --- a/denops/skkeleton/function/henkan.ts +++ b/denops/skkeleton/function/henkan.ts @@ -5,7 +5,7 @@ import { currentLibrary } from "../store.ts"; import { handleKey } from "../keymap.ts"; import { keyToNotation } from "../notation.ts"; import { getOkuriStr } from "../okuri.ts"; -import { HenkanState } from "../state.ts"; +import { HenkanState, initializeState } from "../state.ts"; import { kakutei } from "./common.ts"; import { kakuteiFeed } from "./input.ts"; import { jisyoTouroku } from "./jisyo.ts"; @@ -107,7 +107,21 @@ async function selectCandidates(context: Context) { const candidates = state.candidates.slice(start, start + keys.length); const msg = candidates.map((c, i) => `${keys[i]}: ${c.replace(/;.*/, "")}`) .join(" "); - const keyCode = await denops.call("skkeleton#getchar", msg) as number; + let keyCode: number; + try { + keyCode = await denops.call("skkeleton#getchar", msg) as number; + } catch (e: unknown) { + // Note: Ctrl-C is interrupt + // Manually convert to key code + keyCode = 3; + } + // Cancel select by or or + if (keyCode == 3 || keyCode == 7 || keyCode == 27) { + if (config.immediatelyCancel) { + initializeState(context.state); + } + return; + } const key = String.fromCharCode(keyCode); if (key === " ") { index += 1; From f4ab058bdb9774a93b634b2fdd95b90bd9269bdd Mon Sep 17 00:00:00 2001 From: Shougo Date: Sat, 30 Dec 2023 13:29:35 +0900 Subject: [PATCH 2/2] Update denops/skkeleton/function/henkan.ts --- denops/skkeleton/function/henkan.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/denops/skkeleton/function/henkan.ts b/denops/skkeleton/function/henkan.ts index f1464f75..1fe4a5b4 100644 --- a/denops/skkeleton/function/henkan.ts +++ b/denops/skkeleton/function/henkan.ts @@ -110,7 +110,7 @@ async function selectCandidates(context: Context) { let keyCode: number; try { keyCode = await denops.call("skkeleton#getchar", msg) as number; - } catch (e: unknown) { + } catch (_e: unknown) { // Note: Ctrl-C is interrupt // Manually convert to key code keyCode = 3;