mirror of
https://github.com/wavetermdev/backup.git
synced 2026-08-05 13:57:07 -07:00
add metabarecmds into command completion
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -499,7 +499,7 @@ func getCompType(compPos shparse.CompletionPos) string {
|
||||
return CGTypeCommandMeta
|
||||
|
||||
case shparse.CompTypeCommand:
|
||||
return CGTypeCommand
|
||||
return CGTypeCommandMeta
|
||||
|
||||
case shparse.CompTypeVar:
|
||||
return CGTypeVariable
|
||||
|
||||
Reference in New Issue
Block a user