Skip to content
Merged
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
18 changes: 11 additions & 7 deletions experimental/ssh/internal/vscode/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,29 +215,33 @@ func validateSettings(v hujson.Value, connectionName string) *missingSettings {
func settingsMessage(connectionName string, missing *missingSettings) string {
var lines []string
if missing.portRange {
lines = append(lines, fmt.Sprintf(" \"%s\": {\"%s\": \"%s\"}", serverPickPortsKey, connectionName, portRange))
lines = append(lines, fmt.Sprintf(" \"%s\": {\"%s\": \"%s\"}", serverPickPortsKey, connectionName, portRange))
}
if missing.platform {
lines = append(lines, fmt.Sprintf(" \"%s\": {\"%s\": \"%s\"}", remotePlatformKey, connectionName, remotePlatform))
lines = append(lines, fmt.Sprintf(" \"%s\": {\"%s\": \"%s\"}", remotePlatformKey, connectionName, remotePlatform))
}
if missing.listenOnSocket {
lines = append(lines, fmt.Sprintf(" \"%s\": true // Global setting that affects all remote ssh connections", listenOnSocketKey))
lines = append(lines, fmt.Sprintf(" \"%s\": true // Global setting", listenOnSocketKey))
}
if len(missing.extensions) > 0 {
quoted := make([]string, len(missing.extensions))
for i, ext := range missing.extensions {
quoted[i] = fmt.Sprintf("\"%s\"", ext)
}
lines = append(lines, fmt.Sprintf(" \"%s\": [%s] // Global setting that affects all remote ssh connections", defaultExtensionsKey, strings.Join(quoted, ", ")))
lines = append(lines, fmt.Sprintf(" \"%s\": [%s] // Global setting", defaultExtensionsKey, strings.Join(quoted, ", ")))
}
return strings.Join(lines, "\n")
return " {\n" + strings.Join(lines, ",\n") + "\n }"
}

func promptUserForUpdate(ctx context.Context, ide, connectionName string, missing *missingSettings) (bool, error) {
question := fmt.Sprintf(
"The following settings will be applied to %s for '%s':\n%s\nApply these settings?",
"The following settings will be applied to %s for '%s':\n\n%s\n\nApply these settings?",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Agent Swarm Review] [Nit]

The change from cmdio.AskYesOrNo to cmdio.Ask with manual [Y/n] handling means only exact "y" matches are accepted. strings.EqualFold(strings.TrimSpace(ans), "y") or also accepting "yes" would be more robust.

getIDE(ide).Name, connectionName, settingsMessage(connectionName, missing))
return cmdio.AskYesOrNo(ctx, question)
ans, err := cmdio.Ask(ctx, question+" [Y/n]", "y")
if err != nil {
return false, err
}
return strings.ToLower(ans) == "y", nil
}

func handleMissingFile(ctx context.Context, ide, connectionName, settingsPath string) error {
Expand Down
Loading