From 5171c89e1eaa184e827d1c29486ab026e7c8c73c Mon Sep 17 00:00:00 2001 From: SuperKooks Date: Sat, 8 Jan 2022 14:41:20 +1100 Subject: [PATCH] Fix autocomplete for workspace subcommands --- internal/command/autocomplete.go | 6 +----- internal/command/workspace_delete.go | 1 - internal/command/workspace_new.go | 1 - internal/command/workspace_select.go | 1 - 4 files changed, 1 insertion(+), 8 deletions(-) diff --git a/internal/command/autocomplete.go b/internal/command/autocomplete.go index 4b19c1c95..87e765fe8 100644 --- a/internal/command/autocomplete.go +++ b/internal/command/autocomplete.go @@ -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 diff --git a/internal/command/workspace_delete.go b/internal/command/workspace_delete.go index 654aac581..013db3966 100644 --- a/internal/command/workspace_delete.go +++ b/internal/command/workspace_delete.go @@ -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(""), } diff --git a/internal/command/workspace_new.go b/internal/command/workspace_new.go index 41e657bef..cd28e6986 100644 --- a/internal/command/workspace_new.go +++ b/internal/command/workspace_new.go @@ -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(""), } diff --git a/internal/command/workspace_select.go b/internal/command/workspace_select.go index 1f98ec55e..e257b59d7 100644 --- a/internal/command/workspace_select.go +++ b/internal/command/workspace_select.go @@ -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(""), }