summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/components/InputPrompt.tsx
diff options
context:
space:
mode:
authorDeWitt Clinton <[email protected]>2025-05-20 10:12:07 -0700
committerGitHub <[email protected]>2025-05-20 10:12:07 -0700
commitee702c3139a2fe966407379891cae0e3a148891e (patch)
tree83e4e79ed663699ad1ceaf46f2508a4dc5f4133c /packages/cli/src/ui/components/InputPrompt.tsx
parent6ca446bdeda359339b20aaf024d5cce4234bfe9a (diff)
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.
Diffstat (limited to 'packages/cli/src/ui/components/InputPrompt.tsx')
-rw-r--r--packages/cli/src/ui/components/InputPrompt.tsx21
1 files changed, 1 insertions, 20 deletions
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,