mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-04-26 04:19:27 -07:00
fix: restore linux multi-copy digit capture
This commit is contained in:
@@ -135,12 +135,11 @@ test('createOverlayShortcutRuntimeHandlers reports async failures via OSD', asyn
|
||||
}
|
||||
});
|
||||
|
||||
test('runOverlayShortcutLocalFallback dispatches matching actions with timeout', () => {
|
||||
test('runOverlayShortcutLocalFallback dispatches matching single-step actions', () => {
|
||||
const handled: string[] = [];
|
||||
const matched: Array<{ accelerator: string; allowWhenRegistered: boolean }> = [];
|
||||
const shortcuts = makeShortcuts({
|
||||
copySubtitleMultiple: 'Ctrl+M',
|
||||
multiCopyTimeoutMs: 4321,
|
||||
copySubtitle: 'Ctrl+M',
|
||||
});
|
||||
|
||||
const result = runOverlayShortcutLocalFallback(
|
||||
@@ -169,10 +168,61 @@ test('runOverlayShortcutLocalFallback dispatches matching actions with timeout',
|
||||
);
|
||||
|
||||
assert.equal(result, true);
|
||||
assert.deepEqual(handled, ['copySubtitleMultiple:4321']);
|
||||
assert.deepEqual(handled, ['copySubtitle']);
|
||||
assert.deepEqual(matched, [{ accelerator: 'Ctrl+M', allowWhenRegistered: false }]);
|
||||
});
|
||||
|
||||
test('runOverlayShortcutLocalFallback leaves multi-step numeric shortcuts for renderer handling', () => {
|
||||
const handled: string[] = [];
|
||||
const shortcuts = makeShortcuts({
|
||||
copySubtitleMultiple: 'Ctrl+M',
|
||||
mineSentenceMultiple: 'Ctrl+N',
|
||||
multiCopyTimeoutMs: 4321,
|
||||
});
|
||||
|
||||
const copyResult = runOverlayShortcutLocalFallback(
|
||||
{} as Electron.Input,
|
||||
shortcuts,
|
||||
(_input, accelerator) => accelerator === 'Ctrl+M',
|
||||
{
|
||||
openRuntimeOptions: () => handled.push('openRuntimeOptions'),
|
||||
openJimaku: () => handled.push('openJimaku'),
|
||||
markAudioCard: () => handled.push('markAudioCard'),
|
||||
copySubtitleMultiple: (timeoutMs) => handled.push(`copySubtitleMultiple:${timeoutMs}`),
|
||||
copySubtitle: () => handled.push('copySubtitle'),
|
||||
toggleSecondarySub: () => handled.push('toggleSecondarySub'),
|
||||
updateLastCardFromClipboard: () => handled.push('updateLastCardFromClipboard'),
|
||||
triggerFieldGrouping: () => handled.push('triggerFieldGrouping'),
|
||||
triggerSubsync: () => handled.push('triggerSubsync'),
|
||||
mineSentence: () => handled.push('mineSentence'),
|
||||
mineSentenceMultiple: (timeoutMs) => handled.push(`mineSentenceMultiple:${timeoutMs}`),
|
||||
},
|
||||
);
|
||||
|
||||
const mineResult = runOverlayShortcutLocalFallback(
|
||||
{} as Electron.Input,
|
||||
shortcuts,
|
||||
(_input, accelerator) => accelerator === 'Ctrl+N',
|
||||
{
|
||||
openRuntimeOptions: () => handled.push('openRuntimeOptions'),
|
||||
openJimaku: () => handled.push('openJimaku'),
|
||||
markAudioCard: () => handled.push('markAudioCard'),
|
||||
copySubtitleMultiple: (timeoutMs) => handled.push(`copySubtitleMultiple:${timeoutMs}`),
|
||||
copySubtitle: () => handled.push('copySubtitle'),
|
||||
toggleSecondarySub: () => handled.push('toggleSecondarySub'),
|
||||
updateLastCardFromClipboard: () => handled.push('updateLastCardFromClipboard'),
|
||||
triggerFieldGrouping: () => handled.push('triggerFieldGrouping'),
|
||||
triggerSubsync: () => handled.push('triggerSubsync'),
|
||||
mineSentence: () => handled.push('mineSentence'),
|
||||
mineSentenceMultiple: (timeoutMs) => handled.push(`mineSentenceMultiple:${timeoutMs}`),
|
||||
},
|
||||
);
|
||||
|
||||
assert.equal(copyResult, false);
|
||||
assert.equal(mineResult, false);
|
||||
assert.deepEqual(handled, []);
|
||||
});
|
||||
|
||||
test('runOverlayShortcutLocalFallback passes allowWhenRegistered for secondary-sub toggle', () => {
|
||||
const matched: Array<{ accelerator: string; allowWhenRegistered: boolean }> = [];
|
||||
const shortcuts = makeShortcuts({
|
||||
|
||||
@@ -147,12 +147,6 @@ export function runOverlayShortcutLocalFallback(
|
||||
handlers.markAudioCard();
|
||||
},
|
||||
},
|
||||
{
|
||||
accelerator: shortcuts.copySubtitleMultiple,
|
||||
run: () => {
|
||||
handlers.copySubtitleMultiple(shortcuts.multiCopyTimeoutMs);
|
||||
},
|
||||
},
|
||||
{
|
||||
accelerator: shortcuts.copySubtitle,
|
||||
run: () => {
|
||||
@@ -188,12 +182,6 @@ export function runOverlayShortcutLocalFallback(
|
||||
handlers.mineSentence();
|
||||
},
|
||||
},
|
||||
{
|
||||
accelerator: shortcuts.mineSentenceMultiple,
|
||||
run: () => {
|
||||
handlers.mineSentenceMultiple(shortcuts.multiCopyTimeoutMs);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
for (const action of actions) {
|
||||
|
||||
@@ -1119,6 +1119,32 @@ test('session binding: Ctrl+Shift+O dispatches runtime options locally', async (
|
||||
}
|
||||
});
|
||||
|
||||
test('session binding: copy subtitle multiple captures follow-up digit locally', async () => {
|
||||
const { handlers, testGlobals } = createKeyboardHandlerHarness();
|
||||
|
||||
try {
|
||||
await handlers.setupMpvInputForwarding();
|
||||
handlers.updateSessionBindings([
|
||||
{
|
||||
sourcePath: 'shortcuts.copySubtitleMultiple',
|
||||
originalKey: 'Ctrl+M',
|
||||
key: { code: 'KeyM', modifiers: ['ctrl'] },
|
||||
actionType: 'session-action',
|
||||
actionId: 'copySubtitleMultiple',
|
||||
},
|
||||
] as never);
|
||||
|
||||
testGlobals.dispatchKeydown({ key: 'm', code: 'KeyM', ctrlKey: true });
|
||||
testGlobals.dispatchKeydown({ key: '3', code: 'Digit3' });
|
||||
|
||||
assert.deepEqual(testGlobals.sessionActions, [
|
||||
{ actionId: 'copySubtitleMultiple', payload: { count: 3 } },
|
||||
]);
|
||||
} finally {
|
||||
testGlobals.restore();
|
||||
}
|
||||
});
|
||||
|
||||
test('keyboard mode: h moves left when popup is closed', async () => {
|
||||
const { ctx, handlers, testGlobals } = createKeyboardHandlerHarness();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user