diff --git a/pkg/ui/pages/selection/item.go b/pkg/ui/pages/selection/item.go index b6b3a02fa..94a3729a6 100644 --- a/pkg/ui/pages/selection/item.go +++ b/pkg/ui/pages/selection/item.go @@ -129,7 +129,6 @@ func (d *ItemDelegate) Spacing() int { return 1 } // Update implements list.ItemDelegate. func (d *ItemDelegate) Update(msg tea.Msg, m *list.Model) tea.Cmd { - idx := m.Index() item, ok := m.SelectedItem().(Item) if !ok { return nil @@ -138,10 +137,11 @@ func (d *ItemDelegate) Update(msg tea.Msg, m *list.Model) tea.Cmd { case tea.KeyPressMsg: switch { case key.Matches(msg, d.common.KeyMap.Copy): - d.copiedIdx = idx + visibleIdx := m.Index() + d.copiedIdx = visibleIdx return tea.Batch( tea.SetClipboard(item.Command()), - m.SetItem(idx, item), + m.SetItem(m.GlobalIndex(), item), ) } }