From b8684604f6cbed96e2e247993902e3426178f9c1 Mon Sep 17 00:00:00 2001 From: Awesome Date: Wed, 1 Apr 2026 08:28:57 +0900 Subject: [PATCH] fix: implement IListContext for MigrationsContext to enable keyboard selection MigrationsContext was missing GetSelectedIdx() and GetItemCount(), so it did not satisfy IListContext. The keybinding handler fell through to IScrollableContext, causing arrow keys to scroll the view rather than move the selection. Add the two missing methods and a compile-time interface check. --- pkg/gui/context/migrations_context.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/gui/context/migrations_context.go b/pkg/gui/context/migrations_context.go index 9e065b1..eea09a8 100644 --- a/pkg/gui/context/migrations_context.go +++ b/pkg/gui/context/migrations_context.go @@ -42,6 +42,7 @@ type MigrationsContext struct { } var _ types.Context = &MigrationsContext{} +var _ types.IListContext = &MigrationsContext{} type MigrationsContextOpts struct { Gui *gocui.Gui @@ -276,6 +277,16 @@ func (m *MigrationsContext) SelectPrev() { } } +// GetSelectedIdx returns the index of the currently selected item. +func (m *MigrationsContext) GetSelectedIdx() int { + return m.selected +} + +// GetItemCount returns the number of items in the current tab. +func (m *MigrationsContext) GetItemCount() int { + return len(m.items) +} + // --------------------------------------------------------------------------- // Scroll overrides (list-aware: also update selection) // ---------------------------------------------------------------------------