Skip to content

Commit 292e74c

Browse files
committed
fixup! Show a confirmation when changing a config that can't be auto-reloaded
1 parent e10299a commit 292e74c

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

pkg/gui/gui.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -455,20 +455,22 @@ func (gui *Gui) checkForChangedConfigsThatDontAutoReload(oldConfig *config.UserC
455455
old := reflect.ValueOf(oldConfig).Elem()
456456
new := reflect.ValueOf(newConfig).Elem()
457457
fieldNames := strings.Split(config, ".")
458+
userFacingPath := make([]string, 0, len(fieldNames))
458459
// navigate to the leaves in old and new config
459460
for _, fieldName := range fieldNames {
461+
f, _ := old.Type().FieldByName(fieldName)
462+
userFacingName := f.Tag.Get("yaml")
463+
if userFacingName == "" {
464+
userFacingName = fieldName
465+
}
466+
userFacingPath = append(userFacingPath, userFacingName)
460467
old = old.FieldByName(fieldName)
461468
new = new.FieldByName(fieldName)
462469
}
463470
// if the value has changed, ...
464471
if !old.Equal(new) {
465-
// ... convert the field names to the user-facing names by
466-
// lower-casing the first letter, ...
467-
userFacingName := strings.Join(lo.Map(fieldNames, func(f string, _ int) string {
468-
return strings.ToLower(f[:1]) + f[1:]
469-
}), ".")
470-
// ... and append it to the list of changed configs
471-
changedConfigs = append(changedConfigs, userFacingName)
472+
// ... append it to the list of changed configs
473+
changedConfigs = append(changedConfigs, strings.Join(userFacingPath, "."))
472474
}
473475
}
474476

0 commit comments

Comments
 (0)