fix(ui): prevent repo duplication when copying from filtered list#902
Open
syf2211 wants to merge 1 commit into
Open
fix(ui): prevent repo duplication when copying from filtered list#902syf2211 wants to merge 1 commit into
syf2211 wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes repository list duplication when pressing
cto 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 usedlist.Model.Index()(visible/filtered index) withSetItem(), butSetItem()expects the global index in the unfiltered items slice.Changes
m.GlobalIndex()when callingSetItem()after a copy actioncopiedIdxon the visible index so the "(copied to clipboard)" feedback still renders on the correct rowTests
go vet ./pkg/ui/pages/selection/...— passgo test ./...— pass (includingtestscript)Notes
The bubbles v2 list API documents that
Index()should not be used withSetItem()while filtering;GlobalIndex()is the correct choice. This is the onlySetItem()call site in the repository.Fixes #510