mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-08 04:10:35 -07:00
feat: auto-execute on slash command completion functions (#14584)
This commit is contained in:
@@ -621,16 +621,41 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
|
||||
const isEnterKey = key.name === 'return' && !key.ctrl;
|
||||
|
||||
if (isEnterKey && buffer.text.startsWith('/')) {
|
||||
const command = completion.getCommandFromSuggestion(suggestion);
|
||||
const { isArgumentCompletion, leafCommand } =
|
||||
completion.slashCompletionRange;
|
||||
|
||||
if (command && isAutoExecutableCommand(command)) {
|
||||
if (
|
||||
isArgumentCompletion &&
|
||||
isAutoExecutableCommand(leafCommand)
|
||||
) {
|
||||
// isArgumentCompletion guarantees leafCommand exists
|
||||
const completedText = completion.getCompletedText(suggestion);
|
||||
|
||||
if (completedText) {
|
||||
setExpandedSuggestionIndex(-1);
|
||||
handleSubmit(completedText.trim());
|
||||
return;
|
||||
}
|
||||
} else if (!isArgumentCompletion) {
|
||||
// Existing logic for command name completion
|
||||
const command =
|
||||
completion.getCommandFromSuggestion(suggestion);
|
||||
|
||||
// Only auto-execute if the command has no completion function
|
||||
// (i.e., it doesn't require an argument to be selected)
|
||||
if (
|
||||
command &&
|
||||
isAutoExecutableCommand(command) &&
|
||||
!command.completion
|
||||
) {
|
||||
const completedText =
|
||||
completion.getCompletedText(suggestion);
|
||||
|
||||
if (completedText) {
|
||||
setExpandedSuggestionIndex(-1);
|
||||
handleSubmit(completedText.trim());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user