Skip to content

Commit

Permalink
project sandbox command won't correctly set selected sandbox #547
Browse files Browse the repository at this point in the history
  • Loading branch information
pmi authored and alansemenov committed May 10, 2024
1 parent e270447 commit 49a8b1d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion internal/app/commands/project/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var Sandbox = cli.Command{
var sandboxName string
if c.NArg() > 0 {
sandboxName = c.Args().First()
} else {
} else if pData.Sandbox != "" {
fmt.Fprint(os.Stdout, "\n")
projectName := common.ReadProjectName(".")
question := fmt.Sprintf("\"%s\" is using sandbox \"%s\". Change the project's sandbox", projectName, pData.Sandbox)
Expand Down
12 changes: 6 additions & 6 deletions internal/app/commands/sandbox/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,10 @@ func EnsureSandboxExists(c *cli.Context, options EnsureSandboxOptions) (*Sandbox
}

var selectOptions []string
var selectSandboxes []*Sandbox
if options.ShowCreateOption {
selectOptions = append(selectOptions, CREATE_NEW_BOX)
selectSandboxes = append(selectSandboxes, nil)
}
var boxName, defaultBox string
osWithArch := util.GetCurrentOsWithArch()
Expand All @@ -259,10 +261,11 @@ func EnsureSandboxExists(c *cli.Context, options EnsureSandboxOptions) (*Sandbox
defaultBox = boxName
}
selectOptions = append(selectOptions, boxName)
selectSandboxes = append(selectSandboxes, box)
}

name, optionIndex, err := util.PromptSelect(&util.SelectOptions{
Message: options.SelectBoxMessage,
name, selectIndex, err := util.PromptSelect(&util.SelectOptions{
Message: options.SelectBoxMessage,
Options: selectOptions,
Default: defaultBox,
PageSize: len(selectOptions),
Expand All @@ -274,10 +277,7 @@ func EnsureSandboxExists(c *cli.Context, options EnsureSandboxOptions) (*Sandbox
return newBox, true
}

if options.ShowCreateOption {
optionIndex -= 1 // subtract 1 because of 'new sandbox' option
}
return existingBoxes[optionIndex], false
return selectSandboxes[selectIndex], false
}

func CopyHomeFolder(distroPath, sandboxName string) {
Expand Down

0 comments on commit 49a8b1d

Please sign in to comment.