feat(cli): allow executing commands on perfect match (#4397)

Co-authored-by: Jenna Inouye <jinouye@google.com>
This commit is contained in:
Harold Mciver
2025-07-18 00:55:29 -04:00
committed by GitHub
parent 8497176168
commit de27ea6095
4 changed files with 51 additions and 18 deletions
@@ -162,7 +162,7 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
// - Otherwise, the base is everything EXCEPT the last partial part.
const basePath =
hasTrailingSpace || isParentPath ? parts : parts.slice(0, -1);
const newValue = `/${[...basePath, suggestion].join(' ')} `;
const newValue = `/${[...basePath, suggestion].join(' ')}`;
buffer.setText(newValue);
} else {
@@ -266,6 +266,12 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
return;
}
// If the command is a perfect match, pressing enter should execute it.
if (completion.isPerfectMatch && key.name === 'return') {
handleSubmitAndClear(buffer.text);
return;
}
if (completion.showSuggestions) {
if (completion.suggestions.length > 1) {
if (key.name === 'up') {