소스 검색

feat: allow ctrl+d to exit the app (#3636)

Nathan Thomas 3 달 전
부모
커밋
e630d680dd

+ 11 - 0
packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx

@@ -530,6 +530,17 @@ export function Prompt(props: PromptProps) {
                   setStore("extmarkToPartIndex", new Map())
                   return
                 }
+                if (keybind.match("input_forward_delete", e) && store.prompt.input !== "") {
+                  const cursorOffset = input.cursorOffset
+                  if (cursorOffset < input.plainText.length) {
+                    const text = input.plainText
+                    const newText = text.slice(0, cursorOffset) + text.slice(cursorOffset + 1)
+                    input.setText(newText)
+                    input.cursorOffset = cursorOffset
+                  }
+                  e.preventDefault()
+                  return
+                }
                 if (keybind.match("app_exit", e)) {
                   await exit()
                   return

+ 2 - 1
packages/opencode/src/config/config.ts

@@ -385,7 +385,7 @@ export namespace Config {
         .optional()
         .default("ctrl+x")
         .describe("Leader key for keybind combinations"),
-      app_exit: z.string().optional().default("ctrl+c,<leader>q").describe("Exit the application"),
+      app_exit: z.string().optional().default("ctrl+c,ctrl+d,<leader>q").describe("Exit the application"),
       editor_open: z.string().optional().default("<leader>e").describe("Open external editor"),
       theme_list: z.string().optional().default("<leader>t").describe("List available themes"),
       sidebar_toggle: z.string().optional().default("<leader>b").describe("Toggle sidebar"),
@@ -454,6 +454,7 @@ export namespace Config {
       agent_cycle: z.string().optional().default("tab").describe("Next agent"),
       agent_cycle_reverse: z.string().optional().default("shift+tab").describe("Previous agent"),
       input_clear: z.string().optional().default("ctrl+c").describe("Clear input field"),
+      input_forward_delete: z.string().optional().default("ctrl+d").describe("Forward delete"),
       input_paste: z.string().optional().default("ctrl+v").describe("Paste from clipboard"),
       input_submit: z.string().optional().default("enter").describe("Submit input"),
       input_newline: z

+ 4 - 0
packages/sdk/js/src/gen/types.gen.ts

@@ -134,6 +134,10 @@ export type KeybindsConfig = {
    * Clear input field
    */
   input_clear?: string
+  /**
+   * Forward delete characters in input field
+   */
+  input_forward_delete?: string
   /**
    * Paste from clipboard
    */

+ 2 - 1
packages/web/src/content/docs/keybinds.mdx

@@ -11,7 +11,7 @@ OpenCode has a list of keybinds that you can customize through the OpenCode conf
   "keybinds": {
     "leader": "ctrl+x",
     "app_help": "<leader>h",
-    "app_exit": "ctrl+c,<leader>q",
+    "app_exit": "ctrl+c,ctrl+d,<leader>q",
     "editor_open": "<leader>e",
     "theme_list": "<leader>t",
     "project_init": "<leader>i",
@@ -42,6 +42,7 @@ OpenCode has a list of keybinds that you can customize through the OpenCode conf
     "agent_cycle": "tab",
     "agent_cycle_reverse": "shift+tab",
     "input_clear": "ctrl+c",
+    "input_forward_delete": "ctrl+d",
     "input_paste": "ctrl+v",
     "input_submit": "enter",
     "input_newline": "shift+enter,ctrl+j"