| author | |
| committer | |
| log | 1269b5258097d75f4cb413a0612570a106e32426 |
| tree | 5d2f5d3734dd58e2766cdac7d57d80c83d1ee10c |
| parent | fe79c8e9ee7471a6d32b9c045a19073c236809e6 |
3 files changed, 12 insertions(+), 17 deletions(-)
KEYBINDINGS.md+1-1| ... | ... | @@ -21,7 +21,7 @@ See the full schema for more details: [`packages/contracts/src/keybindings.ts`]( |
| 21 | 21 | [ |
| 22 | 22 | { "key": "mod+j", "command": "terminal.toggle" }, |
| 23 | 23 | { "key": "mod+d", "command": "terminal.split", "when": "terminalFocus" }, |
| 24 | { "key": "mod+shift+d", "command": "terminal.new", "when": "terminalFocus" }, | |
| 24 | { "key": "mod+n", "command": "terminal.new", "when": "terminalFocus" }, | |
| 25 | 25 | { "key": "mod+shift+o", "command": "chat.new" }, |
| 26 | 26 | { "key": "mod+o", "command": "editor.openFavorite" } |
| 27 | 27 | ] |
apps/server/src/keybindings.ts+7-8| ... | ... | @@ -27,7 +27,7 @@ type WhenToken = |
| 27 | 27 | export const DEFAULT_KEYBINDINGS: ReadonlyArray<KeybindingRule> = [ |
| 28 | 28 | { key: "mod+j", command: "terminal.toggle" }, |
| 29 | 29 | { key: "mod+d", command: "terminal.split", when: "terminalFocus" }, |
| 30 | { key: "mod+shift+d", command: "terminal.new", when: "terminalFocus" }, | |
| 30 | { key: "mod+n", command: "terminal.new", when: "terminalFocus" }, | |
| 31 | 31 | { key: "mod+shift+o", command: "chat.new" }, |
| 32 | 32 | { key: "mod+o", command: "editor.openFavorite" }, |
| 33 | 33 | ]; |
| ... | ... | @@ -39,7 +39,10 @@ function normalizeKeyToken(token: string): string { |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | export function parseKeybindingShortcut(value: string): KeybindingShortcut | null { |
| 42 | const rawTokens = value.toLowerCase().split("+").map((token) => token.trim()); | |
| 42 | const rawTokens = value | |
| 43 | .toLowerCase() | |
| 44 | .split("+") | |
| 45 | .map((token) => token.trim()); | |
| 43 | 46 | const tokens = [...rawTokens]; |
| 44 | 47 | let trailingEmptyCount = 0; |
| 45 | 48 | while (tokens[tokens.length - 1] === "") { |
| ... | ... | @@ -220,9 +223,7 @@ export function parseKeybindingWhenExpression(expression: string): KeybindingWhe |
| 220 | 223 | return ast; |
| 221 | 224 | } |
| 222 | 225 | |
| 223 | export function compileResolvedKeybindingRule( | |
| 224 | rule: KeybindingRule, | |
| 225 | ): ResolvedKeybindingRule | null { | |
| 226 | export function compileResolvedKeybindingRule(rule: KeybindingRule): ResolvedKeybindingRule | null { | |
| 226 | 227 | const key = rule.key.trim(); |
| 227 | 228 | if (key.length === 0) return null; |
| 228 | 229 | const shortcut = parseKeybindingShortcut(key); |
| ... | ... | @@ -271,9 +272,7 @@ function compileDefaultKeybindings(): ResolvedKeybindingsConfig { |
| 271 | 272 | |
| 272 | 273 | const DEFAULT_RESOLVED_KEYBINDINGS = compileDefaultKeybindings(); |
| 273 | 274 | |
| 274 | function mergeWithDefaultKeybindings( | |
| 275 | custom: ResolvedKeybindingsConfig, | |
| 276 | ): ResolvedKeybindingsConfig { | |
| 275 | function mergeWithDefaultKeybindings(custom: ResolvedKeybindingsConfig): ResolvedKeybindingsConfig { | |
| 277 | 276 | if (custom.length === 0) { |
| 278 | 277 | return [...DEFAULT_RESOLVED_KEYBINDINGS]; |
| 279 | 278 | } |
apps/server/src/wsServer.test.ts+4-8| ... | ... | @@ -351,7 +351,7 @@ describe("WebSocket Server", () => { |
| 351 | 351 | JSON.stringify([ |
| 352 | 352 | { key: "cmd+j", command: "terminal.toggle" }, |
| 353 | 353 | { key: "mod+d", command: "terminal.split", when: "terminalFocus" }, |
| 354 | { key: "mod+shift+d", command: "terminal.new", when: "terminalFocus" }, | |
| 354 | { key: "mod+n", command: "terminal.new", when: "terminalFocus" }, | |
| 355 | 355 | ]), |
| 356 | 356 | "utf8", |
| 357 | 357 | ); |
| ... | ... | @@ -374,7 +374,7 @@ describe("WebSocket Server", () => { |
| 374 | 374 | keybindings: mergeWithDefaultsForTest([ |
| 375 | 375 | { key: "cmd+j", command: "terminal.toggle" }, |
| 376 | 376 | { key: "mod+d", command: "terminal.split", when: "terminalFocus" }, |
| 377 | { key: "mod+shift+d", command: "terminal.new", when: "terminalFocus" }, | |
| 377 | { key: "mod+n", command: "terminal.new", when: "terminalFocus" }, | |
| 378 | 378 | ]), |
| 379 | 379 | }); |
| 380 | 380 | }); |
| ... | ... | @@ -408,9 +408,7 @@ describe("WebSocket Server", () => { |
| 408 | 408 | expect(response.error).toBeUndefined(); |
| 409 | 409 | expect(response.result).toEqual({ |
| 410 | 410 | cwd: "/my/workspace", |
| 411 | keybindings: mergeWithDefaultsForTest([ | |
| 412 | { key: "mod+j", command: "terminal.toggle" }, | |
| 413 | ]), | |
| 411 | keybindings: mergeWithDefaultsForTest([{ key: "mod+j", command: "terminal.toggle" }]), | |
| 414 | 412 | }); |
| 415 | 413 | expect( |
| 416 | 414 | warnSpy.mock.calls.some(([message]) => |
| ... | ... | @@ -479,9 +477,7 @@ describe("WebSocket Server", () => { |
| 479 | 477 | expect(firstResponse.error).toBeUndefined(); |
| 480 | 478 | expect(firstResponse.result).toEqual({ |
| 481 | 479 | cwd: "/my/workspace", |
| 482 | keybindings: mergeWithDefaultsForTest([ | |
| 483 | { key: "cmd+j", command: "terminal.toggle" }, | |
| 484 | ]), | |
| 480 | keybindings: mergeWithDefaultsForTest([{ key: "cmd+j", command: "terminal.toggle" }]), | |
| 485 | 481 | }); |
| 486 | 482 | |
| 487 | 483 | fs.writeFileSync( |