Fix #4220: allow up/down arrow to toggle history when only one sugges… (#4377)

This commit is contained in:
goldyonatan 2025-07-18 01:30:39 +03:00 committed by GitHub
parent 761ffc6338
commit 6aac93ee07
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 64 additions and 60 deletions

View File

@ -95,7 +95,9 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
const inputHistory = useInputHistory({
userMessages,
onSubmit: handleSubmitAndClear,
isActive: !completion.showSuggestions && !shellModeActive,
isActive:
(!completion.showSuggestions || completion.suggestions.length === 1) &&
!shellModeActive,
currentQuery: buffer.text,
onChange: customSetTextAndResetCompletionSignal,
});
@ -265,6 +267,7 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
}
if (completion.showSuggestions) {
if (completion.suggestions.length > 1) {
if (key.name === 'up') {
completion.navigateUp();
return;
@ -273,6 +276,7 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
completion.navigateDown();
return;
}
}
if (key.name === 'tab' || (key.name === 'return' && !key.ctrl)) {
if (completion.suggestions.length > 0) {
@ -286,7 +290,8 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
}
return;
}
} else {
}
if (!shellModeActive) {
if (key.ctrl && key.name === 'p') {
inputHistory.navigateUp();
@ -341,7 +346,6 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
}
return;
}
}
// Newline insertion
if (key.name === 'return' && (key.ctrl || key.meta || key.paste)) {