From adca87e9db26d9da8020a5d84ebaa7e4f4dc730b Mon Sep 17 00:00:00 2001 From: sawka Date: Thu, 11 Aug 2022 10:21:45 -0700 Subject: [PATCH] better directory vs file completion --- pkg/cmdrunner/cmdrunner.go | 9 ++++++--- pkg/sstore/updatebus.go | 12 ++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/pkg/cmdrunner/cmdrunner.go b/pkg/cmdrunner/cmdrunner.go index d5c3eed48..22cc3471d 100644 --- a/pkg/cmdrunner/cmdrunner.go +++ b/pkg/cmdrunner/cmdrunner.go @@ -480,9 +480,9 @@ func makeInfoFromComps(compType string, comps []string, hasMore bool) sstore.Upd sort.Strings(comps) update := sstore.InfoUpdate{ Info: &sstore.InfoMsgType{ - InfoTitle: fmt.Sprintf("%s completions", compType), - InfoStrings: comps, - InfoStringsMore: hasMore, + InfoTitle: fmt.Sprintf("%s completions", compType), + InfoComps: comps, + InfoCompsMore: hasMore, }, } return update @@ -508,6 +508,9 @@ func longestPrefix(root string, comps []string) string { if len(comps) == 1 { comp := comps[0] if len(comp) >= len(root) && strings.HasPrefix(comp, root) { + if strings.HasSuffix(comp, "/") { + return comps[0] + } return comps[0] + " " } } diff --git a/pkg/sstore/updatebus.go b/pkg/sstore/updatebus.go index 9a969148b..62a1f4eac 100644 --- a/pkg/sstore/updatebus.go +++ b/pkg/sstore/updatebus.go @@ -75,12 +75,12 @@ func (LineUpdate) UpdateType() string { } type InfoMsgType struct { - InfoTitle string `json:"infotitle"` - InfoError string `json:"infoerror,omitempty"` - InfoMsg string `json:"infomsg,omitempty"` - InfoStrings []string `json:"infostrings"` - InfoStringsMore bool `json:"infostringsmore"` - TimeoutMs int64 `json:"timeoutms,omitempty"` + InfoTitle string `json:"infotitle"` + InfoError string `json:"infoerror,omitempty"` + InfoMsg string `json:"infomsg,omitempty"` + InfoComps []string `json:"infocomps"` + InfoCompsMore bool `json:"infocompssmore"` + TimeoutMs int64 `json:"timeoutms,omitempty"` } type CmdLineType struct {