mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-20 23:20:46 +00:00
* feat(shortcuts): toggle the host list with Ctrl/Cmd+Shift+B Ctrl/Cmd+B already switches broadcast mode and stays available to a focused terminal. The new shortcut reuses the existing host-tree toggle. Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com> * fix(shortcuts): let the host list chord through Monaco and idle terminals Editor focus inside Monaco can toggle the host list. The chord is consumed only when that toggle runs, matching broadcast. Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com>
70 lines
2.5 KiB
TypeScript
70 lines
2.5 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
|
|
import { getTerminalPassthroughActions } from '../application/state/useGlobalHotkeys.ts';
|
|
import en from '../application/i18n/locales/en.ts';
|
|
import zhCN from '../application/i18n/locales/zh-CN.ts';
|
|
import zhTW from '../application/i18n/locales/zh-TW.ts';
|
|
import { findActiveSystemShortcutConflict } from './activeKeyBindings.ts';
|
|
import { DEFAULT_KEY_BINDINGS, matchesKeyBinding } from './models/keyBindings.ts';
|
|
|
|
test('host list toggle defaults to Ctrl/Cmd+Shift+B and leaves Ctrl/Cmd+B on broadcast', () => {
|
|
const binding = DEFAULT_KEY_BINDINGS.find((entry) => entry.id === 'toggle-host-tree');
|
|
|
|
assert.equal(binding?.action, 'toggleHostTree');
|
|
assert.equal(binding?.label, 'Toggle Host List');
|
|
assert.equal(binding?.category, 'app');
|
|
assert.equal(binding?.pc, 'Ctrl + Shift + B');
|
|
assert.equal(binding?.mac, '⌘ + Shift + B');
|
|
|
|
assert.equal(
|
|
findActiveSystemShortcutConflict('Ctrl + B', 'pc', DEFAULT_KEY_BINDINGS)?.id,
|
|
'broadcast',
|
|
);
|
|
assert.equal(
|
|
findActiveSystemShortcutConflict('⌘ + B', 'mac', DEFAULT_KEY_BINDINGS)?.id,
|
|
'broadcast',
|
|
);
|
|
assert.equal(
|
|
findActiveSystemShortcutConflict('Ctrl + Shift + B', 'pc', DEFAULT_KEY_BINDINGS)?.id,
|
|
'toggle-host-tree',
|
|
);
|
|
assert.equal(
|
|
findActiveSystemShortcutConflict('⌘ + Shift + B', 'mac', DEFAULT_KEY_BINDINGS)?.id,
|
|
'toggle-host-tree',
|
|
);
|
|
|
|
assert.deepEqual(
|
|
DEFAULT_KEY_BINDINGS.filter((entry) => entry.pc === 'Ctrl + Shift + B').map((entry) => entry.id),
|
|
['toggle-host-tree'],
|
|
);
|
|
assert.deepEqual(
|
|
DEFAULT_KEY_BINDINGS.filter((entry) => entry.mac === '⌘ + Shift + B').map((entry) => entry.id),
|
|
['toggle-host-tree'],
|
|
);
|
|
|
|
assert.equal(getTerminalPassthroughActions().has('toggleHostTree'), false);
|
|
assert.equal(matchesKeyBinding({
|
|
key: 'B',
|
|
code: 'KeyB',
|
|
ctrlKey: true,
|
|
metaKey: false,
|
|
altKey: false,
|
|
shiftKey: true,
|
|
} as KeyboardEvent, binding?.pc ?? '', false), true);
|
|
assert.equal(matchesKeyBinding({
|
|
key: 'b',
|
|
code: 'KeyB',
|
|
ctrlKey: true,
|
|
metaKey: false,
|
|
altKey: false,
|
|
shiftKey: false,
|
|
} as KeyboardEvent, binding?.pc ?? '', false), false);
|
|
});
|
|
|
|
test('host list shortcut label is localized in English and Chinese', () => {
|
|
assert.equal(en['settings.shortcuts.binding.toggle-host-tree'], 'Toggle Host List');
|
|
assert.equal(zhCN['settings.shortcuts.binding.toggle-host-tree'], '切换主机列表');
|
|
assert.equal(zhTW['settings.shortcuts.binding.toggle-host-tree'], '切換主機列表');
|
|
});
|