add metabarecmds into command completion

This commit is contained in:
sawka
2023-10-26 00:01:52 -07:00
parent 267b035fc8
commit 04cdab6f74
3 changed files with 17 additions and 2 deletions
+3
View File
@@ -19,6 +19,9 @@ class InfoMsg extends React.Component<{}, {}> {
if (s.startsWith("^/")) {
return s.substr(1);
}
if (s.startsWith("^")) {
return s.substr(1);
}
let slashIdx = s.lastIndexOf("/");
if (slashIdx == s.length - 1) {
slashIdx = s.lastIndexOf("/", slashIdx - 1);
+13 -1
View File
@@ -1738,10 +1738,22 @@ func simpleCompCommandMeta(ctx context.Context, prefix string, compCtx comp.Comp
compsMeta, _ := simpleCompMeta(ctx, prefix, compCtx, nil)
return comp.CombineCompReturn(comp.CGTypeCommandMeta, compsCmd, compsMeta), nil
} else {
return comp.DoSimpleComp(ctx, comp.CGTypeCommand, prefix, compCtx, nil)
compsCmd, _ := comp.DoSimpleComp(ctx, comp.CGTypeCommand, prefix, compCtx, nil)
compsBareCmd, _ := simpleCompBareCmds(ctx, prefix, compCtx, nil)
return comp.CombineCompReturn(comp.CGTypeCommand, compsCmd, compsBareCmd), nil
}
}
func simpleCompBareCmds(ctx context.Context, prefix string, compCtx comp.CompContext, args []interface{}) (*comp.CompReturn, error) {
rtn := comp.CompReturn{}
for _, bmc := range BareMetaCmds {
if strings.HasPrefix(bmc.CmdStr, prefix) {
rtn.Entries = append(rtn.Entries, comp.CompEntry{Word: bmc.CmdStr, IsMetaCmd: true})
}
}
return &rtn, nil
}
func simpleCompMeta(ctx context.Context, prefix string, compCtx comp.CompContext, args []interface{}) (*comp.CompReturn, error) {
rtn := comp.CompReturn{}
validCommands := getValidCommands()
+1 -1
View File
@@ -499,7 +499,7 @@ func getCompType(compPos shparse.CompletionPos) string {
return CGTypeCommandMeta
case shparse.CompTypeCommand:
return CGTypeCommand
return CGTypeCommandMeta
case shparse.CompTypeVar:
return CGTypeVariable