Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore/open vscode logs #1535

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/agent/container/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ func (cmd *SetupContainerCmd) installIDE(setupInfo *config.Result, ide *provider
}

func (cmd *SetupContainerCmd) setupVSCode(setupInfo *config.Result, ideOptions map[string]config2.OptionValue, flavor vscode.Flavor, log log.Logger) error {
log.Debugf("Setup %s...", flavor)
log.Debugf("Setup %s...", flavor.DisplayName())
vsCodeConfiguration := config.GetVSCodeConfiguration(setupInfo.MergedConfig)
settings := ""
if len(vsCodeConfiguration.Settings) > 0 {
Expand Down
16 changes: 10 additions & 6 deletions pkg/ide/vscode/open.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package vscode

import (
"context"
"errors"
"fmt"
"os/exec"
"runtime"
Expand All @@ -13,15 +14,18 @@ import (
)

func Open(ctx context.Context, workspace, folder string, newWindow bool, flavor Flavor, log log.Logger) error {
log.Infof("Starting %s...", flavor)
err := openViaCLI(ctx, workspace, folder, newWindow, flavor, log)
if err != nil {
log.Debugf("Error opening %s via cli: %v", flavor, err)
} else {
log.Infof("Starting %s...", flavor.DisplayName())
cliErr := openViaCLI(ctx, workspace, folder, newWindow, flavor, log)
if cliErr == nil {
return nil
}

browserErr := openViaBrowser(workspace, folder, newWindow, flavor, log)
if browserErr == nil {
return nil
}

return openViaBrowser(workspace, folder, newWindow, flavor, log)
return errors.Join(cliErr, browserErr)
}

func openViaBrowser(workspace, folder string, newWindow bool, flavor Flavor, log log.Logger) error {
Expand Down
17 changes: 17 additions & 0 deletions pkg/ide/vscode/vscode.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,23 @@ const (
FlavorCodium Flavor = "codium"
)

func (f Flavor) DisplayName() string {
switch f {
case FlavorStable:
return "VSCode"
case FlavorInsiders:
return "VSCode Insiders"
case FlavorCursor:
return "Cursor"
case FlavorPositron:
return "positron"
case FlavorCodium:
return "VSCodium"
default:
return "VSCode"
}
}

var Options = ide.Options{
OpenNewWindow: {
Name: OpenNewWindow,
Expand Down
Loading