Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions KEYBINDINGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ See the full schema for more details: [`packages/contracts/src/keybindings.ts`](
```json
[
{ "key": "mod+j", "command": "terminal.toggle" },
{ "key": "ctrl+`", "command": "terminal.toggle" },
{ "key": "mod+d", "command": "terminal.split", "when": "terminalFocus" },
{ "key": "mod+n", "command": "terminal.new", "when": "terminalFocus" },
{ "key": "mod+w", "command": "terminal.close", "when": "terminalFocus" },
Expand Down
9 changes: 8 additions & 1 deletion apps/server/src/keybindings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,14 @@ it.layer(NodeServices.layer)("keybindings", (it) => {
});

const persisted = yield* readKeybindingsConfig(keybindingsConfigPath);
assert.isFalse(persisted.some((entry) => entry.command === "terminal.toggle"));
// The conflicting mod+j binding for terminal.toggle should NOT be added
assert.isFalse(
persisted.some((entry) => entry.command === "terminal.toggle" && entry.key === "mod+j"),
);
// But the non-conflicting ctrl+` binding for terminal.toggle should still be added
assert.isTrue(
persisted.some((entry) => entry.command === "terminal.toggle" && entry.key === "ctrl+`"),
);
assert.isTrue(persisted.some((entry) => entry.command === "script.custom-action.run"));

assert.isTrue(
Expand Down
1 change: 1 addition & 0 deletions apps/server/src/keybindings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ type WhenToken =

export const DEFAULT_KEYBINDINGS: ReadonlyArray<KeybindingRule> = [
{ key: "mod+j", command: "terminal.toggle" },
{ key: "ctrl+`", command: "terminal.toggle" },
{ key: "mod+d", command: "terminal.split", when: "terminalFocus" },
{ key: "mod+n", command: "terminal.new", when: "terminalFocus" },
{ key: "mod+w", command: "terminal.close", when: "terminalFocus" },
Expand Down
29 changes: 29 additions & 0 deletions apps/web/src/keybindings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@ function compile(bindings: TestBinding[]): ResolvedKeybindingsConfig {

const DEFAULT_BINDINGS = compile([
{ shortcut: modShortcut("j"), command: "terminal.toggle" },
{
shortcut: {
key: "`",
metaKey: false,
ctrlKey: true,
shiftKey: false,
altKey: false,
modKey: false,
},
command: "terminal.toggle",
},
{
shortcut: modShortcut("d"),
command: "terminal.split",
Expand Down Expand Up @@ -116,6 +127,24 @@ describe("isTerminalToggleShortcut", () => {
isTerminalToggleShortcut(event({ ctrlKey: true }), DEFAULT_BINDINGS, { platform: "Win32" }),
);
});

it("matches Ctrl+` on all platforms", () => {
assert.isTrue(
isTerminalToggleShortcut(event({ key: "`", ctrlKey: true }), DEFAULT_BINDINGS, {
platform: "MacIntel",
}),
);
assert.isTrue(
isTerminalToggleShortcut(event({ key: "`", ctrlKey: true }), DEFAULT_BINDINGS, {
platform: "Win32",
}),
);
assert.isTrue(
isTerminalToggleShortcut(event({ key: "`", ctrlKey: true }), DEFAULT_BINDINGS, {
platform: "Linux",
}),
);
});
});

describe("split/new/close terminal shortcuts", () => {
Expand Down
8 changes: 4 additions & 4 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading