Skip to content

Commit 38dd520

Browse files
nwthomasjunkfactory
authored andcommitted
feat: allow ctrl+d to exit the app (sst#3636)
1 parent c20e662 commit 38dd520

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,17 @@ export function Prompt(props: PromptProps) {
530530
setStore("extmarkToPartIndex", new Map())
531531
return
532532
}
533+
if (keybind.match("input_forward_delete", e) && store.prompt.input !== "") {
534+
const cursorOffset = input.cursorOffset
535+
if (cursorOffset < input.plainText.length) {
536+
const text = input.plainText
537+
const newText = text.slice(0, cursorOffset) + text.slice(cursorOffset + 1)
538+
input.setText(newText)
539+
input.cursorOffset = cursorOffset
540+
}
541+
e.preventDefault()
542+
return
543+
}
533544
if (keybind.match("app_exit", e)) {
534545
await exit()
535546
return

packages/opencode/src/config/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ export namespace Config {
382382
.optional()
383383
.default("ctrl+x")
384384
.describe("Leader key for keybind combinations"),
385-
app_exit: z.string().optional().default("ctrl+c,<leader>q").describe("Exit the application"),
385+
app_exit: z.string().optional().default("ctrl+c,ctrl+d,<leader>q").describe("Exit the application"),
386386
editor_open: z.string().optional().default("<leader>e").describe("Open external editor"),
387387
theme_list: z.string().optional().default("<leader>t").describe("List available themes"),
388388
sidebar_toggle: z.string().optional().default("<leader>b").describe("Toggle sidebar"),
@@ -451,6 +451,7 @@ export namespace Config {
451451
agent_cycle: z.string().optional().default("tab").describe("Next agent"),
452452
agent_cycle_reverse: z.string().optional().default("shift+tab").describe("Previous agent"),
453453
input_clear: z.string().optional().default("ctrl+c").describe("Clear input field"),
454+
input_forward_delete: z.string().optional().default("ctrl+d").describe("Forward delete"),
454455
input_paste: z.string().optional().default("ctrl+v").describe("Paste from clipboard"),
455456
input_submit: z.string().optional().default("enter").describe("Submit input"),
456457
input_newline: z

packages/sdk/js/src/gen/types.gen.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ export type KeybindsConfig = {
134134
* Clear input field
135135
*/
136136
input_clear?: string
137+
/**
138+
* Forward delete characters in input field
139+
*/
140+
input_forward_delete?: string
137141
/**
138142
* Paste from clipboard
139143
*/

packages/web/src/content/docs/keybinds.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ OpenCode has a list of keybinds that you can customize through the OpenCode conf
1111
"keybinds": {
1212
"leader": "ctrl+x",
1313
"app_help": "<leader>h",
14-
"app_exit": "ctrl+c,<leader>q",
14+
"app_exit": "ctrl+c,ctrl+d,<leader>q",
1515
"editor_open": "<leader>e",
1616
"theme_list": "<leader>t",
1717
"project_init": "<leader>i",
@@ -42,6 +42,7 @@ OpenCode has a list of keybinds that you can customize through the OpenCode conf
4242
"agent_cycle": "tab",
4343
"agent_cycle_reverse": "shift+tab",
4444
"input_clear": "ctrl+c",
45+
"input_forward_delete": "ctrl+d",
4546
"input_paste": "ctrl+v",
4647
"input_submit": "enter",
4748
"input_newline": "shift+enter,ctrl+j"

0 commit comments

Comments
 (0)