better directory vs file completion

This commit is contained in:
sawka
2022-08-11 10:21:45 -07:00
parent 81c564aca9
commit adca87e9db
2 changed files with 12 additions and 9 deletions
+6 -3
View File
@@ -480,9 +480,9 @@ func makeInfoFromComps(compType string, comps []string, hasMore bool) sstore.Upd
sort.Strings(comps) sort.Strings(comps)
update := sstore.InfoUpdate{ update := sstore.InfoUpdate{
Info: &sstore.InfoMsgType{ Info: &sstore.InfoMsgType{
InfoTitle: fmt.Sprintf("%s completions", compType), InfoTitle: fmt.Sprintf("%s completions", compType),
InfoStrings: comps, InfoComps: comps,
InfoStringsMore: hasMore, InfoCompsMore: hasMore,
}, },
} }
return update return update
@@ -508,6 +508,9 @@ func longestPrefix(root string, comps []string) string {
if len(comps) == 1 { if len(comps) == 1 {
comp := comps[0] comp := comps[0]
if len(comp) >= len(root) && strings.HasPrefix(comp, root) { if len(comp) >= len(root) && strings.HasPrefix(comp, root) {
if strings.HasSuffix(comp, "/") {
return comps[0]
}
return comps[0] + " " return comps[0] + " "
} }
} }
+6 -6
View File
@@ -75,12 +75,12 @@ func (LineUpdate) UpdateType() string {
} }
type InfoMsgType struct { type InfoMsgType struct {
InfoTitle string `json:"infotitle"` InfoTitle string `json:"infotitle"`
InfoError string `json:"infoerror,omitempty"` InfoError string `json:"infoerror,omitempty"`
InfoMsg string `json:"infomsg,omitempty"` InfoMsg string `json:"infomsg,omitempty"`
InfoStrings []string `json:"infostrings"` InfoComps []string `json:"infocomps"`
InfoStringsMore bool `json:"infostringsmore"` InfoCompsMore bool `json:"infocompssmore"`
TimeoutMs int64 `json:"timeoutms,omitempty"` TimeoutMs int64 `json:"timeoutms,omitempty"`
} }
type CmdLineType struct { type CmdLineType struct {