Fix autocomplete for workspace subcommands

This commit is contained in:
SuperKooks 2022-01-08 14:41:20 +11:00
parent 1e9075b4fa
commit 5171c89e1e
4 changed files with 1 additions and 8 deletions

View File

@ -19,11 +19,7 @@ var completePredictModuleSource = complete.PredictAnything
type completePredictSequence []complete.Predictor
func (s completePredictSequence) Predict(a complete.Args) []string {
// Only one level of command is stripped off the prefix of a.Completed
// here, so nested subcommands like "workspace new" will need to provide
// dummy entries (e.g. complete.PredictNothing) as placeholders for
// all but the first subcommand. For example, "workspace new" needs
// one placeholder for the argument "new".
// Nested subcommands do not require any placeholder entry for their subcommand name.
idx := len(a.Completed)
if idx >= len(s) {
return nil

View File

@ -190,7 +190,6 @@ func (c *WorkspaceDeleteCommand) Run(args []string) int {
func (c *WorkspaceDeleteCommand) AutocompleteArgs() complete.Predictor {
return completePredictSequence{
complete.PredictNothing, // the "select" subcommand itself (already matched)
c.completePredictWorkspaceName(),
complete.PredictDirs(""),
}

View File

@ -167,7 +167,6 @@ func (c *WorkspaceNewCommand) Run(args []string) int {
func (c *WorkspaceNewCommand) AutocompleteArgs() complete.Predictor {
return completePredictSequence{
complete.PredictNothing, // the "new" subcommand itself (already matched)
complete.PredictAnything,
complete.PredictDirs(""),
}

View File

@ -117,7 +117,6 @@ func (c *WorkspaceSelectCommand) Run(args []string) int {
func (c *WorkspaceSelectCommand) AutocompleteArgs() complete.Predictor {
return completePredictSequence{
complete.PredictNothing, // the "select" subcommand itself (already matched)
c.completePredictWorkspaceName(),
complete.PredictDirs(""),
}