From ee702c3139a2fe966407379891cae0e3a148891e Mon Sep 17 00:00:00 2001
From: DeWitt Clinton <dclinton@gmail.com>
Date: Tue, 20 May 2025 10:12:07 -0700
Subject: Implement additional readline-like keybindings, including alt-left
 arrow and alt-right arrow. (#443)

This change adds keybinding support for:

  - `Ctrl+B`: Moves the cursor backward one character.
  - `Ctrl+F`: Moves the cursor forward one character.
  - `Alt+Left Arrow`: Moves the cursor backward one word.
  - `Alt+Right Arrow`: Moves the cursor forward one word.

Closes b/411469305.
---
 packages/cli/src/ui/components/InputPrompt.tsx | 21 +--------------------
 1 file changed, 1 insertion(+), 20 deletions(-)

(limited to 'packages/cli/src/ui/components/InputPrompt.tsx')

diff --git a/packages/cli/src/ui/components/InputPrompt.tsx b/packages/cli/src/ui/components/InputPrompt.tsx
index f77ac4d6..38af2a8c 100644
--- a/packages/cli/src/ui/components/InputPrompt.tsx
+++ b/packages/cli/src/ui/components/InputPrompt.tsx
@@ -24,7 +24,6 @@ interface InputPromptProps {
   userMessages: readonly string[];
   navigateSuggestionUp: () => void;
   navigateSuggestionDown: () => void;
-  setEditorState: (updater: (prevState: EditorState) => EditorState) => void;
   onClearScreen: () => void;
   shellModeActive: boolean;
   setShellModeActive: (value: boolean) => void;
@@ -48,7 +47,6 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
   navigateSuggestionUp,
   navigateSuggestionDown,
   resetCompletion,
-  setEditorState,
   onClearScreen,
   shellModeActive,
   setShellModeActive,
@@ -114,12 +112,7 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
   );
 
   const inputPreprocessor = useCallback(
-    (
-      input: string,
-      key: Key,
-      _currentText?: string,
-      _cursorOffset?: number,
-    ) => {
+    (input: string, key: Key) => {
       if (input === '!' && query === '' && !showSuggestions) {
         setShellModeActive(!shellModeActive);
         onChangeAndMoveCursor(''); // Clear the '!' from input
@@ -156,17 +149,6 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
         }
       } else {
         // Keybindings when suggestions are not shown
-        if (key.ctrl && input === 'a') {
-          setEditorState((s) => ({ key: s.key + 1, initialCursorOffset: 0 }));
-          return true;
-        }
-        if (key.ctrl && input === 'e') {
-          setEditorState((s) => ({
-            key: s.key + 1,
-            initialCursorOffset: query.length,
-          }));
-          return true;
-        }
         if (key.ctrl && input === 'l') {
           onClearScreen();
           return true;
@@ -193,7 +175,6 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
       activeSuggestionIndex,
       handleSubmit,
       inputHistory,
-      setEditorState,
       onClearScreen,
       shellModeActive,
       setShellModeActive,
-- 
cgit v1.2.3

