mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-05-26 12:55:16 -07:00
fix: delegate multi-line digit selection to visible overlay (#78)
This commit is contained in:
@@ -670,6 +670,21 @@ test('numeric selection ignores non-digit keys instead of falling through to oth
|
||||
}
|
||||
});
|
||||
|
||||
test('numeric selection start focuses overlay for follow-up digit keys', async () => {
|
||||
const { handlers, testGlobals } = createKeyboardHandlerHarness();
|
||||
|
||||
try {
|
||||
await handlers.setupMpvInputForwarding();
|
||||
handlers.beginSessionNumericSelection('copySubtitleMultiple');
|
||||
|
||||
assert.equal(testGlobals.focusMainWindowCalls() > 0, true);
|
||||
assert.equal(testGlobals.windowFocusCalls() > 0, true);
|
||||
assert.equal(testGlobals.overlayFocusCalls.length > 0, true);
|
||||
} finally {
|
||||
testGlobals.restore();
|
||||
}
|
||||
});
|
||||
|
||||
test('keyboard mode: left and right move token selection while popup remains open', async () => {
|
||||
const { ctx, handlers, testGlobals } = createKeyboardHandlerHarness();
|
||||
|
||||
|
||||
@@ -147,6 +147,7 @@ export function createKeyboardHandlers(
|
||||
|
||||
function startPendingNumericSelection(
|
||||
actionId: 'copySubtitleMultiple' | 'mineSentenceMultiple',
|
||||
timeoutMs: number = ctx.state.sessionActionTimeoutMs,
|
||||
): void {
|
||||
cancelPendingNumericSelection(false);
|
||||
const timeoutMessage = actionId === 'copySubtitleMultiple' ? 'Copy timeout' : 'Mine timeout';
|
||||
@@ -159,15 +160,17 @@ export function createKeyboardHandlers(
|
||||
timeout: setTimeout(() => {
|
||||
pendingNumericSelection = null;
|
||||
showSessionSelectionMessage(timeoutMessage);
|
||||
}, ctx.state.sessionActionTimeoutMs),
|
||||
}, timeoutMs),
|
||||
};
|
||||
showSessionSelectionMessage(promptMessage);
|
||||
}
|
||||
|
||||
function beginSessionNumericSelection(
|
||||
actionId: 'copySubtitleMultiple' | 'mineSentenceMultiple',
|
||||
timeoutMs?: number,
|
||||
): void {
|
||||
startPendingNumericSelection(actionId);
|
||||
startPendingNumericSelection(actionId, timeoutMs);
|
||||
restoreOverlayKeyboardFocus();
|
||||
}
|
||||
|
||||
function handlePendingNumericSelection(e: KeyboardEvent): boolean {
|
||||
|
||||
@@ -530,6 +530,12 @@ function registerModalOpenHandlers(): void {
|
||||
}
|
||||
|
||||
function registerKeyboardCommandHandlers(): void {
|
||||
window.electronAPI.onSessionNumericSelectionStart((payload) => {
|
||||
runGuarded('session:numeric-selection-start', () => {
|
||||
keyboardHandlers.beginSessionNumericSelection(payload.actionId, payload.timeoutMs);
|
||||
});
|
||||
});
|
||||
|
||||
window.electronAPI.onKeyboardModeToggleRequested(() => {
|
||||
runGuarded('keyboard-mode-toggle:requested', () => {
|
||||
keyboardHandlers.handleKeyboardModeToggleRequested();
|
||||
|
||||
Reference in New Issue
Block a user