Normalize shortcut spaces before fil

This commit is contained in:
2026-02-15 23:41:57 -08:00
parent dae1f817e0
commit 1ab7e6e1da
14 changed files with 1114 additions and 15 deletions

View File

@@ -8,6 +8,12 @@ export function createKeyboardHandlers(
handleSubsyncKeydown: (e: KeyboardEvent) => boolean;
handleKikuKeydown: (e: KeyboardEvent) => boolean;
handleJimakuKeydown: (e: KeyboardEvent) => boolean;
handleSessionHelpKeydown: (e: KeyboardEvent) => boolean;
openSessionHelpModal: (opening: {
bindingKey: "KeyH" | "KeyK";
fallbackUsed: boolean;
fallbackUnavailable: boolean;
}) => void;
saveInvisiblePositionEdit: () => void;
cancelInvisiblePositionEdit: () => void;
setInvisiblePositionEditMode: (enabled: boolean) => void;
@@ -62,6 +68,47 @@ export function createKeyboardHandlers(
);
}
function resolveSessionHelpChordBinding(): {
bindingKey: "KeyH" | "KeyK";
fallbackUsed: boolean;
fallbackUnavailable: boolean;
} {
const firstChoice = "KeyH";
if (!ctx.state.keybindingsMap.has("KeyH")) {
return {
bindingKey: firstChoice,
fallbackUsed: false,
fallbackUnavailable: false,
};
}
if (ctx.state.keybindingsMap.has("KeyK")) {
return {
bindingKey: "KeyK",
fallbackUsed: true,
fallbackUnavailable: true,
};
}
return {
bindingKey: "KeyK",
fallbackUsed: true,
fallbackUnavailable: false,
};
}
function applySessionHelpChordBinding(): void {
CHORD_MAP.delete("KeyH");
CHORD_MAP.delete("KeyK");
const info = resolveSessionHelpChordBinding();
CHORD_MAP.set(info.bindingKey, {
type: "electron",
action: () => {
options.openSessionHelpModal(info);
},
});
}
function handleInvisiblePositionEditKeydown(e: KeyboardEvent): boolean {
if (!ctx.platform.isInvisibleLayer) return false;
@@ -163,6 +210,10 @@ export function createKeyboardHandlers(
options.handleJimakuKeydown(e);
return;
}
if (ctx.state.sessionHelpModalOpen) {
options.handleSessionHelpKeydown(e);
return;
}
if (ctx.state.chordPending) {
const modifierKeys = [
@@ -202,6 +253,7 @@ export function createKeyboardHandlers(
!e.repeat
) {
e.preventDefault();
applySessionHelpChordBinding();
ctx.state.chordPending = true;
ctx.state.chordTimeout = setTimeout(() => {
resetChord();