Merge pull request #30316 from superkooks/main
Fix autocomplete for workspace subcommands
This commit is contained in:
commit
5a9bc76d1a
|
@ -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
|
||||
|
|
|
@ -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(""),
|
||||
}
|
||||
|
|
|
@ -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(""),
|
||||
}
|
||||
|
|
|
@ -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(""),
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue