Skip to content

Commit 5a9bc76

Browse files
authored
Merge pull request hashicorp#30316 from superkooks/main
Fix autocomplete for workspace subcommands
2 parents f9603d3 + 5171c89 commit 5a9bc76

4 files changed

Lines changed: 1 addition & 8 deletions

File tree

‎internal/command/autocomplete.go‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@ var completePredictModuleSource = complete.PredictAnything
1919
type completePredictSequence []complete.Predictor
2020

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

‎internal/command/workspace_delete.go‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ func (c *WorkspaceDeleteCommand) Run(args []string) int {
190190

191191
func (c *WorkspaceDeleteCommand) AutocompleteArgs() complete.Predictor {
192192
return completePredictSequence{
193-
complete.PredictNothing, // the "select" subcommand itself (already matched)
194193
c.completePredictWorkspaceName(),
195194
complete.PredictDirs(""),
196195
}

‎internal/command/workspace_new.go‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ func (c *WorkspaceNewCommand) Run(args []string) int {
167167

168168
func (c *WorkspaceNewCommand) AutocompleteArgs() complete.Predictor {
169169
return completePredictSequence{
170-
complete.PredictNothing, // the "new" subcommand itself (already matched)
171170
complete.PredictAnything,
172171
complete.PredictDirs(""),
173172
}

‎internal/command/workspace_select.go‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ func (c *WorkspaceSelectCommand) Run(args []string) int {
117117

118118
func (c *WorkspaceSelectCommand) AutocompleteArgs() complete.Predictor {
119119
return completePredictSequence{
120-
complete.PredictNothing, // the "select" subcommand itself (already matched)
121120
c.completePredictWorkspaceName(),
122121
complete.PredictDirs(""),
123122
}

0 commit comments

Comments
 (0)