mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-12-02 00:59:32 +01:00
feat(shortcuts): rebindable previous/next session, duplicate-chord refusal, rebinds stay out of the PTY
This commit is contained in:
1 parent
3d59e59e37
commit
1aeabdfd55
8 files changed
+116
-34
No files matched your search
@@ -14,10 +14,11 @@ describe('keyboard shortcuts', () => {
|
||||
});
|
||||
|
||||
it('provides Option+bracket shortcuts for previous and next session', () => {
|
||||
expect(appSource).toContain("e.code === 'BracketLeft'");
|
||||
expect(appSource).toContain("e.code === 'BracketRight'");
|
||||
expect(appSource).toContain('this.prevSession()');
|
||||
expect(appSource).toContain('this.nextSession()');
|
||||
// Registry entries (so they can be rebound), matched by physical key code.
|
||||
expect(appSource).toMatch(/id: 'previous-session'[\s\S]*?code: 'BracketLeft'[\s\S]*?action: 'previousSession'/);
|
||||
expect(appSource).toMatch(/id: 'next-session-alt'[\s\S]*?code: 'BracketRight'[\s\S]*?action: 'nextSession'/);
|
||||
expect(appSource).toContain('previousSession: () => this.prevSession()');
|
||||
expect(appSource).toContain('nextSession: () => this.nextSession()');
|
||||
});
|
||||
|
||||
it('suppresses xterm PTY injection for the same physical Alt nav codes (no ESC leak)', () => {
|
||||
@@ -53,7 +54,7 @@ describe('keyboard shortcuts', () => {
|
||||
// getShortcutRegistry() + matchesShortcutEvent() so overrides and per-shortcut
|
||||
// disables (App Settings → Shortcuts) actually take effect.
|
||||
expect(appSource).not.toContain('const SHORTCUTS = [');
|
||||
expect(appSource).toContain('const SHORTCUT_ACTIONS = {');
|
||||
expect(appSource).toContain('const SHORTCUT_ACTIONS = this._shortcutActions();');
|
||||
expect(appSource).toContain('for (const shortcut of this.getShortcutRegistry())');
|
||||
expect(appSource).toContain('if (this.matchesShortcutEvent(e, shortcut))');
|
||||
expect(appSource).toContain('if (shortcut.disabled || !shortcut.action) continue;');
|
||||
@@ -84,4 +85,14 @@ describe('keyboard shortcuts', () => {
|
||||
expect(readme).toContain('`Ctrl/Cmd+C`');
|
||||
expect(readme).toContain('`Ctrl+Shift+C`');
|
||||
});
|
||||
|
||||
it('keeps a user-rebound chord out of the PTY and refuses duplicate bindings', () => {
|
||||
const tile = readFileSync('src/web/public/terminal-tile.js', 'utf8');
|
||||
const settings = readFileSync('src/web/public/settings-ui.js', 'utf8');
|
||||
expect(appSource).toContain('isUserBoundShortcutEvent(e) {');
|
||||
expect(terminalUiSource).toContain('this.isUserBoundShortcutEvent?.(ev)) return false');
|
||||
expect(tile).toContain('global.app?.isUserBoundShortcutEvent?.(ev)) return false');
|
||||
expect(settings).toContain('this.findShortcutConflict(e, shortcutId)');
|
||||
expect(settings).toContain("return 'Switch to Tab N'");
|
||||
});
|
||||
});
|
||||
@@ -138,8 +138,8 @@ describe('smart-copy wiring invariants', () => {
|
||||
// the copy action were reachable from there, Ctrl+C would be swallowed with
|
||||
// no selection and the user would lose the interrupt key.
|
||||
const actionsBlock = APP_SOURCE.slice(
|
||||
APP_SOURCE.indexOf('const SHORTCUT_ACTIONS = {'),
|
||||
APP_SOURCE.indexOf('// Use capture to handle before terminal')
|
||||
APP_SOURCE.indexOf('_shortcutActions() {'),
|
||||
APP_SOURCE.indexOf('isUserBoundShortcutEvent(e) {')
|
||||
);
|
||||
expect(actionsBlock.length).toBeGreaterThan(0);
|
||||
expect(actionsBlock).not.toContain('copyTerminalSelection');
|
||||
|
||||
Reference in new issue
Block a user