fix(cli): override j/k navigation in settings dialog to fix search input conflict (#22800)

This commit is contained in:
Sehoon Shon
2026-03-17 15:08:45 -04:00
committed by GitHub
parent fc51e50bc6
commit b211f30d95
3 changed files with 57 additions and 5 deletions

View File

@@ -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
? {