From 9ce2a389b9394491c90e65e6455510c8e677a7eb Mon Sep 17 00:00:00 2001 From: Jan Hensel Date: Tue, 2 Jul 2024 00:57:21 +0200 Subject: [PATCH] fix: Fix editor field ordering maybe this time --- internal/ui/panes/composite_editor_ui_pane.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/internal/ui/panes/composite_editor_ui_pane.go b/internal/ui/panes/composite_editor_ui_pane.go index 8d3cd171..675da460 100644 --- a/internal/ui/panes/composite_editor_ui_pane.go +++ b/internal/ui/panes/composite_editor_ui_pane.go @@ -245,7 +245,16 @@ func translateEditorsCompositeToTUI(e *editors.Composite, minX, minY, maxWidth, var children []ui.BoxRepresentation[edit.Editor] computedHeight := 1 rollingY := minY + 1 - for _, child := range e.GetFields() { + for _, childID := range e.GetFieldOrder() { + child, ok := e.GetFields()[childID] + if !ok { + log.Warn(). + Str("id", childID). + Int("num-fields-per-order", len(e.GetFieldOrder())). + Int("num-fields-per-map", len(e.GetFields())). + Msg("found composite editor inconsistency: field-ID in order but not in map of fields") + continue + } childBoxRepresentation, err := translateEditorsEditorToTUI(child, minX+1, rollingY, maxWidth-2, maxHeight-2) if err != nil { return ui.BoxRepresentation[edit.Editor]{}, fmt.Errorf("error translating child '%s' (%s)", child.GetID(), err.Error())