Skip to content

fix(settings): prevent j/k navigation keys from intercepting edit buffer input#21865

Merged
Adib234 merged 6 commits intogoogle-gemini:mainfrom
student-ankitpandit:fix/settings-string-input-vim-keys
Mar 13, 2026
Merged

fix(settings): prevent j/k navigation keys from intercepting edit buffer input#21865
Adib234 merged 6 commits intogoogle-gemini:mainfrom
student-ankitpandit:fix/settings-string-input-vim-keys

Conversation

@student-ankitpandit
Copy link
Contributor

@student-ankitpandit student-ankitpandit commented Mar 10, 2026

Summary

Fixes the keybinding conflict in the settings edit mode where pressing 'j' or 'k' while typing in a string input field (e.g. Plan Directory) would trigger vim-style navigation instead of inserting the character into the edit buffer.

Details

When a settings field has a string value type (e.g. Plan Directory), pressing 'j' or 'k' while in edit mode was being intercepted by the vim-style navigation handler before reaching the input buffer.

The fix adds !key.insertable check to both DIALOG_NAVIGATION_UP and DIALOG_NAVIGATION_DOWN handlers in edit mode, so that:

  • Arrow keys (↑↓) → still navigate between settings
  • Letter keys (j/k) → now correctly type into the input field

This mirrors the existing fix already in place for the search box, where the same !key.insertable pattern was already being used.

Related Issues

Fixes #21746

How to Validate

  1. Run gemini-cli: gemini
  2. Open settings: /settings
  3. Navigate to Plan Directory using arrow keys
  4. Press Enter to enter edit mode
  5. Type a path containing 'j' or 'k' e.g. /projects/jekyll
  6. Verify that 'j' and 'k' appear in the input field instead of triggering navigation
  7. Verify that arrow keys ↑↓ still navigate correctly between settings

Edge Case (uppercase J and K)

  1. Press Enter on Plan Directory again to edit
  2. Type a path containing 'J' or 'K' e.g. /Projects/Jekyll
  3. Verify that 'J' and 'K' appear in the input field instead of triggering navigation
  4. Verify that arrow keys ↑↓ still navigate correctly between settings

Pre-Merge Checklist

  • [] Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • [] Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • [] MacOS
      • [] npm run
      • [] npx
      • [] Docker
      • [] Podman
      • [] Seatbelt
    • [] Windows
      • [] npm run
      • [] npx
      • [] Docker
    • Linux
      • npm run
      • [] npx
      • [] Docker

NOTE: Tested on Ubuntu (Linux) via WSL on Windows.
Fix is platform-independent as it only modifies
keyboard event logic.

@student-ankitpandit student-ankitpandit requested a review from a team as a code owner March 10, 2026 12:30
@gemini-cli gemini-cli bot added priority/p1 Important and should be addressed in the near term. area/core Issues related to User Interface, OS Support, Core Functionality help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! labels Mar 10, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 addresses a keybinding conflict within the settings dialog. Specifically, it prevents the 'j' and 'k' keys from being incorrectly interpreted as navigation commands when a user is actively typing in an input field. The changes ensure that these keys are correctly inserted into the edit buffer, while preserving arrow key navigation functionality.

Highlights

  • Keybinding Conflict Fix: Resolved an issue where 'j' and 'k' keys triggered vim-style navigation in settings edit mode instead of inserting characters into input fields.
  • Conditional Navigation Handling: Implemented a check for !key.insertable in DIALOG_NAVIGATION_UP and DIALOG_NAVIGATION_DOWN handlers during edit mode.
  • Consistent Behavior: Mirrored the existing fix in the search box to ensure consistent key handling across the application.
Changelog
  • BaseSettingsDialog.tsx
    • Prevented j/k navigation keys from intercepting edit buffer input in settings dialog.
Activity
  • The pull request includes a detailed description of the issue and the implemented solution.
  • It also provides clear steps for validation and considers edge cases (uppercase J and K).
  • The author has validated the fix on Linux and indicated that it is platform-independent.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

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

  1. 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.

Copy link
Contributor

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

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 resolves a keybinding conflict in the settings dialog where 'j' and 'k' keys were being intercepted as navigation commands instead of being treated as text input. The changes correctly add a !key.insertable check to the navigation handlers for both edit mode and when the search box is enabled. This ensures that arrow keys continue to function for navigation, while 'j' and 'k' can be correctly typed into input fields. The implementation appears to effectively resolve the issue.

Note: Security Review did not run due to the size of the PR.

@Adib234 Adib234 self-assigned this Mar 10, 2026
@Adib234
Copy link
Contributor

Adib234 commented Mar 10, 2026

Thank you for this PR, I've verified it works locally on my end. Can you resolve merge conflicts and add tests for this?

@student-ankitpandit
Copy link
Contributor Author

student-ankitpandit commented Mar 10, 2026

Thank you for this PR, I've verified it works locally on my end. Can you resolve merge conflicts and add tests for this?

Yeah, I am working on conflicts.

@psinha40898
Copy link
Contributor

psinha40898 commented Mar 10, 2026

fyi you might be better off re applying the change on an up to date branch and force pushing b/c basesettings was refactored heavily

@student-ankitpandit student-ankitpandit force-pushed the fix/settings-string-input-vim-keys branch from 868de0a to dcf664e Compare March 10, 2026 14:59
@student-ankitpandit
Copy link
Contributor Author

student-ankitpandit commented Mar 10, 2026

fyi you might be better off re applying the change on an up to date branch and force pushing b/c basesettings was refactored heavily

Re-applied the changes to the updated branch and forced push the changes there.

@psinha40898
Copy link
Contributor

@student-ankitpandit
The failing test is because the previous test infrastructure did not account for letting users type j and k into search

I would recommend to minimize the scope of this fix only to the inline editing buffer, this means that users will still not be able to use j and k inside of search. notably this behavior has existed since even before #18963

Then your tests will pass and you will have resolved the issue regarding inline editing, another issue should be filed to discuss a path to resolve the search UX.

Copy link
Contributor

@psinha40898 psinha40898 left a comment

Choose a reason for hiding this comment

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

IMO the cleanest solution here is to confine your change to just the inline edit buffer if possible.

After that, I think we should be using effectiveFocusSection or else your changes won't work when the UI conditionally hides the Scope menu and the user presses tab

deferring to the assigned reviewer @Adib234 from here

Good luck

@student-ankitpandit student-ankitpandit force-pushed the fix/settings-string-input-vim-keys branch from 018c0ff to 938477b Compare March 10, 2026 17:23
// can be typed into the search box instead. Arrow keys always work.
if (
keyMatchers[Command.DIALOG_NAVIGATION_UP](key) &&
!(searchEnabled && key.insertable)
Copy link
Contributor

@psinha40898 psinha40898 Mar 10, 2026

Choose a reason for hiding this comment

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

this will not pass cli ci unless you revert this change. the solution here is beyond the scope of your PR. fix edit buffer not search

@student-ankitpandit student-ankitpandit force-pushed the fix/settings-string-input-vim-keys branch from d32942d to 98b5743 Compare March 10, 2026 18:42
@student-ankitpandit
Copy link
Contributor Author

My bad, I forgot to add the GEMIN_API_KEY in the repo secret of my fork.

@student-ankitpandit
Copy link
Contributor Author

student-ankitpandit commented Mar 10, 2026

All 26 test cases has been passed, but there is the issue with the branch. I try to update the branch many times but after a while again the pop-up appears again saying your branch is out of date.

@psinha40898
Copy link
Contributor

psinha40898 commented Mar 10, 2026

there's no issue. you don't need to update the branch if there are no merge conflicts detected. just add a regression test (confer with llm and use it as learning exp if u never did this before)

after that the pr should be good to go

@student-ankitpandit
Copy link
Contributor Author

student-ankitpandit commented Mar 11, 2026

there's no issue. you don't need to update the branch if there are no merge conflicts detected. just add a regression test (confer with llm and use it as learning exp if u never did this before)

after that the pr should be good to go

Sure i will do and btw thanks for correcting me.

@student-ankitpandit
Copy link
Contributor Author

Edit buffer works as execpted, but i'm bit concern about the search it's still can't accept k and j as insertable keywords in the search of the settings. User still can't search about a setting start with k and j.

Copy link
Contributor

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

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 correctly addresses a keybinding conflict in the settings edit mode. The change prevents the 'j' and 'k' keys from being intercepted as navigation commands when editing a field, allowing them to be used as character inputs. The fix, which involves checking the key.insertable property, is targeted and effectively resolves the issue while maintaining existing navigation functionality with arrow keys. The implementation is sound and I have no further recommendations.

@psinha40898
Copy link
Contributor

Edit buffer works as execpted, but i'm bit concern about the search it's still can't accept k and j as insertable keywords in the search of the settings. User still can't search about a setting start with k and j.

you need to add a regression test

fixing search is beyond the scope of your pull request

@psinha40898
Copy link
Contributor

A regression test is a test in BaseSettingsDialog.test.tsx that will pass if j and k can be entered into the edit buffer please add this test and please do not worry about search

Copy link

@GlatnahHapa GlatnahHapa left a comment

Choose a reason for hiding this comment

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

Update

@psinha40898
Copy link
Contributor

Thank you! lgtm

@Adib234

Thank you for letting me help review it should be good to go now

@student-ankitpandit
Copy link
Contributor Author

Everything looks goods to me.

@Adib234
Copy link
Contributor

Adib234 commented Mar 13, 2026

Thanks for your review @psinha40898 !

@Adib234 Adib234 added this pull request to the merge queue Mar 13, 2026
Merged via the queue into google-gemini:main with commit c156bac Mar 13, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Issues related to User Interface, OS Support, Core Functionality help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! priority/p1 Important and should be addressed in the near term.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot enter 'j' or 'k' into Settings where the value is a string

4 participants