fix(completion): offer unique hostnames without instance prefix
bash (and zsh without a matcher) only accept candidates that start with the typed text, so "fsn1-bx1<Tab>" found nothing when every candidate was qualified as "prod/…". Hostnames that exist in only one instance are now offered bare; names present in several instances stay qualified. Connecting to a bare name still checks every instance for ambiguity, so the connection behavior is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6243514def
commit
091f5cc518
5 files changed
+80
-4
No files matched your search
+3
-4
@@ -339,14 +339,13 @@ func rootCmd() *cobra.Command {
|
||||
c := cache.New(cfg.CachePath(), cfg.Cache.TTL)
|
||||
_ = c.Load()
|
||||
|
||||
hosts := c.Search(toComplete)
|
||||
sort.Slice(hosts, func(i, j int) bool { return hosts[i].Name < hosts[j].Name })
|
||||
hosts := hostCompletions(c.All(), toComplete)
|
||||
if limit := cfg.Completion.MaxResults; limit > 0 && len(hosts) > limit {
|
||||
hosts = hosts[:limit]
|
||||
}
|
||||
completions := make([]cobra.Completion, 0, len(hosts))
|
||||
for _, e := range hosts {
|
||||
completions = append(completions, cobra.Completion(e.Name))
|
||||
for _, host := range hosts {
|
||||
completions = append(completions, cobra.Completion(host))
|
||||
}
|
||||
// Subcommands at the end, after all hostnames.
|
||||
for _, sub := range cmd.Commands() {
|
||||
|
||||
Reference in new issue
Block a user