feat(input): add undo/redo shortcuts with Ctrl+Z and Ctrl+R#4625
feat(input): add undo/redo shortcuts with Ctrl+Z and Ctrl+R#4625jacob314 merged 19 commits intogoogle-gemini:mainfrom
Conversation
There was a problem hiding this comment.
Summary of Changes
Hello @masiafrest, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request introduces crucial undo and redo capabilities to the CLI's input prompt, allowing users to recover from accidental key presses and maintain their workflow within the command-line interface. The implementation integrates seamlessly with the existing text buffer logic, providing a familiar text editing experience.
Highlights
- Input Prompt Functionality: Implemented standard undo (Ctrl+Z) and redo (Ctrl+R) keyboard shortcuts directly within the CLI's input prompt, leveraging existing
text-buffercapabilities to enhance user experience and prevent data loss. - Documentation Update: Added a new section to the CLI documentation (
docs/cli/commands.md) detailing the newly introduced input prompt shortcuts for undo and redo. - Test Coverage: Introduced new unit tests for the
InputPromptcomponent to verify thatCtrl+Zcorrectly triggers the undo functionality andCtrl+Rtriggers the redo functionality.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Code Review
This pull request introduces undo (Ctrl+Z) and redo (Ctrl+R) shortcuts to the CLI input prompt, which is a great usability improvement. The code changes are well-contained, tested, and documented. My review focuses on a minor correctness issue with shortcut handling to ensure a consistent and intuitive user experience.
jacob314
left a comment
There was a problem hiding this comment.
thanks for the pull request. It would be good to get proper undo and redo shortcuts. please add that directly to text-buffer.ts rather than InputPrompt unless the behavior depends on functionality only available in InputPrompt.
|
any chance you can update this to use text-buffer.ts over the next couple days? would love to be able to land this as a lot of users are asking for undo+redo. |
f7dbfda to
d4e9968
Compare
will move it to |
8ba3f32 to
f3c986e
Compare
Implement undo/redo functionality in the input prompt using Ctrl+Z and Ctrl+R shortcuts Update documentation to include the new shortcuts Add corresponding test cases
f3c986e to
b113c76
Compare
mattKorwel
left a comment
There was a problem hiding this comment.
@masiafrest I think this one is all good to go, setting to merge when tests pass. cc @jacob314
jacob314
left a comment
There was a problem hiding this comment.
Sorry we have to figure out an alternative shortcut to Ctrl+R as Ctrl+R is also important for reverse search.
|
Actually, I see there is another PR that adds terminal search as ctrl+r. #5539 I think that's a more natural fit for that key combo. marking as needs changes so we can figure out the right keys. |
…emini#4625) Co-authored-by: Jacob Richman <jacob314@gmail.com> Co-authored-by: matt korwel <matt.korwel@gmail.com>
…emini#4625) Co-authored-by: Jacob Richman <jacob314@gmail.com> Co-authored-by: matt korwel <matt.korwel@gmail.com>

TLDR
This PR implements undo (Ctrl+Z) and redo (Ctrl+R) functionality directly within the CLI's input prompt, leveraging existing capabilities to prevent data loss from accidental key presses.
Ctrl+Y is yolo mode so to avoid keymaps conflict choose Ctrl+R for redo
Dive Deeper
Users often type prompts directly into the CLI, and accidental key presses (e.g., Cmd+Delete on macOS instead of Option+Delete) can lead to the complete loss of carefully crafted input. This forces users to resort to external notepads, which disrupts workflow and reduces efficiency.
This change maps the standard keyboard shortcuts for undo and redo to the input prompt, providing a crucial safety net. This improves user experience by offering a familiar text editing feature and enhances productivity by allowing users to stay within the CLI for prompt composition.
The implementation leverages existing undo/redo capabilities within the
text-buffer.tsshared component.Reviewer Test Plan
To validate this change, reviewers can:
npm build && npm startCtrl+Zmultiple times to observe the undo functionality.Ctrl+Rmultiple times to observe the redo functionality.Testing Matrix
Note: The undo/redo functionality is specific to the input prompt UI and should work consistently across different execution environments (npm run, npx). Docker, Podman, and Seatbelt are not directly relevant to the input prompt's text manipulation features.
Linked issues / bugs
Fixes #3509