Skip to content

fix(ui): prevent repo duplication when copying from filtered list#902

Open
syf2211 wants to merge 1 commit into
charmbracelet:mainfrom
syf2211:fix/510-copy-filtered-repo-duplication
Open

fix(ui): prevent repo duplication when copying from filtered list#902
syf2211 wants to merge 1 commit into
charmbracelet:mainfrom
syf2211:fix/510-copy-filtered-repo-duplication

Conversation

@syf2211

@syf2211 syf2211 commented Jun 25, 2026

Copy link
Copy Markdown

Summary

Fixes repository list duplication when pressing c to copy a clone command while the list is filtered.

Motivation

When filtering repositories and pressing c, the selected repository was duplicated in the list. The copy handler used list.Model.Index() (visible/filtered index) with SetItem(), but SetItem() expects the global index in the unfiltered items slice.

Changes

  • Use m.GlobalIndex() when calling SetItem() after a copy action
  • Keep copiedIdx on the visible index so the "(copied to clipboard)" feedback still renders on the correct row

Tests

  • go vet ./pkg/ui/pages/selection/... — pass
  • go test ./... — pass (including testscript)

Notes

The bubbles v2 list API documents that Index() should not be used with SetItem() while filtering; GlobalIndex() is the correct choice. This is the only SetItem() call site in the repository.

Fixes #510

When the repository list is filtered, list.Model.Index() returns the
visible index while SetItem expects the unfiltered index. Using Index()
with SetItem duplicated the selected repository in the list.

Fixes charmbracelet#510
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Copy command duplicating repositories in list

2 participants