diff --git a/docs/cli/commands.md b/docs/cli/commands.md index dc7fc2169c..a3427c9315 100644 --- a/docs/cli/commands.md +++ b/docs/cli/commands.md @@ -380,6 +380,16 @@ That's it! You can now run your command in the CLI. First, you might add a file Gemini CLI will then execute the multi-line prompt defined in your TOML file. +## Input Prompt Shortcuts + +These shortcuts apply directly to the input prompt for text manipulation. + +- **Undo:** + - **Keyboard shortcut:** Press **Ctrl+z** to undo the last action in the input prompt. + +- **Redo:** + - **Keyboard shortcut:** Press **Ctrl+Shift+Z** to redo the last undone action in the input prompt. + ## At commands (`@`) At commands are used to include the content of files or directories as part of your prompt to Gemini. These commands include git-aware filtering. diff --git a/packages/cli/src/ui/components/InputPrompt.test.tsx b/packages/cli/src/ui/components/InputPrompt.test.tsx index 888fff0bca..99d46d7016 100644 --- a/packages/cli/src/ui/components/InputPrompt.test.tsx +++ b/packages/cli/src/ui/components/InputPrompt.test.tsx @@ -127,13 +127,13 @@ describe('InputPrompt', () => { killLineLeft: vi.fn(), openInExternalEditor: vi.fn(), newline: vi.fn(), + undo: vi.fn(), + redo: vi.fn(), backspace: vi.fn(), preferredCol: null, selectionAnchor: null, insert: vi.fn(), del: vi.fn(), - undo: vi.fn(), - redo: vi.fn(), replaceRange: vi.fn(), deleteWordLeft: vi.fn(), deleteWordRight: vi.fn(), diff --git a/packages/cli/src/ui/components/shared/text-buffer.ts b/packages/cli/src/ui/components/shared/text-buffer.ts index b2d6f8b178..a18f4c9c82 100644 --- a/packages/cli/src/ui/components/shared/text-buffer.ts +++ b/packages/cli/src/ui/components/shared/text-buffer.ts @@ -1924,11 +1924,23 @@ export function useTextBuffer({ ) backspace(); else if (key.name === 'delete' || (key.ctrl && key.name === 'd')) del(); + else if (key.ctrl && !key.shift && key.name === 'z') undo(); + else if (key.ctrl && key.shift && key.name === 'z') redo(); else if (input && !key.ctrl && !key.meta) { insert(input, { paste: key.paste }); } }, - [newline, move, deleteWordLeft, deleteWordRight, backspace, del, insert], + [ + newline, + move, + deleteWordLeft, + deleteWordRight, + backspace, + del, + insert, + undo, + redo, + ], ); const renderedVisualLines = useMemo(