Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions cli/completer.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ func (t *autoCompleter) Do(line []rune, pos int) (options [][]rune, offset int)
})
}
for _, item := range argOptions {
if strings.HasPrefix(item.Value, argInput) {
if strings.HasPrefix(item.Value, argInput) || (len(item.Detail) > 0 && strings.HasPrefix(item.Detail, argInput)) {
filteredOptions = append(filteredOptions, item)
}
}
Expand All @@ -457,12 +457,14 @@ func (t *autoCompleter) Do(line []rune, pos int) (options [][]rune, offset int)
}
for _, item := range filteredOptions {
option := item.Value + " "
if len(filteredOptions) > 1 && len(item.Detail) > 0 {
if len(filteredOptions) > 0 && len(item.Detail) > 0 {
Copy link
Preview

Copilot AI Aug 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The condition change from > 1 to > 0 means details will now always be shown when they exist, even for single options. This could clutter the display unnecessarily. Consider if this change aligns with the intended UX behavior.

Suggested change
if len(filteredOptions) > 0 && len(item.Detail) > 0 {
if len(filteredOptions) > 1 && len(item.Detail) > 0 {

Copilot uses AI. Check for mistakes.

option += fmt.Sprintf("(%v)", item.Detail)
}
if strings.HasPrefix(option, argInput) {
options = append(options, []rune(option[len(argInput):]))
offset = len(argInput)
} else if len(item.Detail) > 0 && strings.HasPrefix(item.Detail, argInput) {
options = append(options, []rune(option))
Copy link
Preview

Copilot AI Aug 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When matching on detail, the full option string is returned without adjusting the offset. This means the completion will include the entire option text, potentially overwriting the user's input. The offset should be set to 0 when returning the full option.

Suggested change
options = append(options, []rune(option))
options = append(options, []rune(option))
offset = 0

Copilot uses AI. Check for mistakes.

}
}
return
Expand Down
23 changes: 19 additions & 4 deletions vendor/github.com/chzyer/readline/complete.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.