Skip to content

Commit

Permalink
copy chain items slice explictly
Browse files Browse the repository at this point in the history
  • Loading branch information
RoryQ committed Sep 6, 2024
1 parent e318eea commit def32e6
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,13 @@ func iif[T any](cond bool, a, b T) T {
func (c Chain) ResetCurrent(to ChainIssue) Chain {
newChain := c
newChain.Current = to
for i := range c.Items {
c.Items[i].IsCurrent = false
if c.Items[i].ChainIssue.IsSame(to) {
c.Items[i].IsCurrent = true
newChain.Items = []ChainItem{}
for _, item := range c.Items {
item.IsCurrent = false
if item.ChainIssue.IsSame(to) {
item.IsCurrent = true
}
newChain.Items = append(newChain.Items, item)
}
return newChain
}
Expand Down

0 comments on commit def32e6

Please sign in to comment.