Skip to content

feat(cli): support home key in input prompt#2364

Closed
olk wants to merge 10 commits into
google-gemini:mainfrom
olk:main
Closed

feat(cli): support home key in input prompt#2364
olk wants to merge 10 commits into
google-gemini:mainfrom
olk:main

Conversation

@olk

@olk olk commented Jun 28, 2025

Copy link
Copy Markdown
Contributor

Adds support for the "Home" key to move the cursor to the beginning of the input prompt.

This provides an alternative to the existing "Ctrl+A" shortcut for the same functionality. A corresponding test case has been added to verify the new key binding.

#2193

TLDR

Dive Deeper

Reviewer Test Plan

Testing Matrix

🍏 🪟 🐧
npm run
npx
Docker
Podman - -
Seatbelt - -

Linked issues / bugs

Adds support for the "Home" key to move the cursor to the beginning of the input prompt.

This provides an alternative to the existing "Ctrl+A" shortcut for the same functionality. A corresponding test case has been added to verify the new key binding.
@olk olk requested a review from a team as a code owner June 28, 2025 06:54
@google-cla

google-cla Bot commented Jun 28, 2025

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

olk added 3 commits June 28, 2025 13:08
Adds support for the 'End' key to move the cursor to the end of the input line in the interactive prompt.

This enhances user experience by providing a common and intuitive keyboard shortcut, complementing the existing `Ctrl+E` binding.
@umairidris

Copy link
Copy Markdown
Contributor

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for the "Home" and "End" keys in the input prompt, aliasing them to the existing Ctrl+A and Ctrl+E shortcuts. There are redundant calls to buffer.move() in the implementation where both buffer.move() and buffer.moveToOffset() are called for these key presses. The move() call is unnecessary as moveToOffset() already achieves the desired behavior of moving to the start/end of the entire buffer. This redundancy can lead to confusion and future maintenance issues. I've suggested removing the redundant calls and the corresponding test expectations to improve code clarity and correctness.

Comment thread packages/cli/src/ui/components/InputPrompt.test.tsx
Comment thread packages/cli/src/ui/components/InputPrompt.test.tsx
Comment thread packages/cli/src/ui/components/InputPrompt.tsx Outdated
Comment thread packages/cli/src/ui/components/InputPrompt.tsx Outdated
@olk

olk commented Jun 29, 2025

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for the 'Home' and 'End' keys to the input prompt, allowing the user to move the cursor to the beginning or end of the entire input text. This provides an alternative to the existing 'Ctrl+A' and 'Ctrl+E' shortcuts. The changes include updating the key handling logic and adding corresponding test cases.

My review found an issue in the implementation where a redundant function call is made in both the 'Home' and 'End' key handlers. While this doesn't break the functionality, it's a logic flaw that should be corrected for code clarity and maintainability.

Comment thread packages/cli/src/ui/components/InputPrompt.tsx
@olk

olk commented Jun 30, 2025

Copy link
Copy Markdown
Contributor Author

gemini /review - review only code that belongs to the PR - do NOT review code that is NOT part of the PR

@olk

olk commented Jul 1, 2025

Copy link
Copy Markdown
Contributor Author

gemini /review

@olk olk closed this Jul 1, 2025
@sripasg sripasg added the size/s A small PR label Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/s A small PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants