mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-20 10:10:56 -07:00
fix(cli): override j/k navigation in settings dialog to fix search input conflict (#22800)
This commit is contained in:
@@ -43,6 +43,8 @@ import {
|
||||
BaseSettingsDialog,
|
||||
type SettingsDialogItem,
|
||||
} from './shared/BaseSettingsDialog.js';
|
||||
import { useKeyMatchers } from '../hooks/useKeyMatchers.js';
|
||||
import { Command, KeyBinding } from '../key/keyBindings.js';
|
||||
|
||||
interface FzfResult {
|
||||
item: string;
|
||||
@@ -60,6 +62,11 @@ interface SettingsDialogProps {
|
||||
|
||||
const MAX_ITEMS_TO_SHOW = 8;
|
||||
|
||||
const KEY_UP = new KeyBinding('up');
|
||||
const KEY_CTRL_P = new KeyBinding('ctrl+p');
|
||||
const KEY_DOWN = new KeyBinding('down');
|
||||
const KEY_CTRL_N = new KeyBinding('ctrl+n');
|
||||
|
||||
// Create a snapshot of the initial per-scope state of Restart Required Settings
|
||||
// This creates a nested map of the form
|
||||
// restartRequiredSetting -> Map { scopeName -> value }
|
||||
@@ -336,6 +343,18 @@ export function SettingsDialog({
|
||||
onSelect(undefined, selectedScope as SettingScope);
|
||||
}, [onSelect, selectedScope]);
|
||||
|
||||
const globalKeyMatchers = useKeyMatchers();
|
||||
const settingsKeyMatchers = useMemo(
|
||||
() => ({
|
||||
...globalKeyMatchers,
|
||||
[Command.DIALOG_NAVIGATION_UP]: (key: Key) =>
|
||||
KEY_UP.matches(key) || KEY_CTRL_P.matches(key),
|
||||
[Command.DIALOG_NAVIGATION_DOWN]: (key: Key) =>
|
||||
KEY_DOWN.matches(key) || KEY_CTRL_N.matches(key),
|
||||
}),
|
||||
[globalKeyMatchers],
|
||||
);
|
||||
|
||||
// Custom key handler for restart key
|
||||
const handleKeyPress = useCallback(
|
||||
(key: Key, _currentItem: SettingsDialogItem | undefined): boolean => {
|
||||
@@ -371,6 +390,7 @@ export function SettingsDialog({
|
||||
onItemClear={handleItemClear}
|
||||
onClose={handleClose}
|
||||
onKeyPress={handleKeyPress}
|
||||
keyMatchers={settingsKeyMatchers}
|
||||
footer={
|
||||
showRestartPrompt
|
||||
? {
|
||||
|
||||
Reference in New Issue
Block a user