Skip to content

Commit

Permalink
fix: clipboard history not correctly handling items to spare from rem…
Browse files Browse the repository at this point in the history
…oval
  • Loading branch information
abenz1267 committed Jan 21, 2025
1 parent 1f80b10 commit a3a4fb9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.12.9-git
0.12.9
26 changes: 24 additions & 2 deletions internal/modules/clipboard/clipboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,34 @@ func (c *Clipboard) watch() {

if len(c.items) >= c.max {
c.items = slices.Clone(c.items[:c.max])
c.items = append(c.items, toSpareItems...)

for _, v := range toSpareItems {
if !slices.ContainsFunc(c.items, func(item ClipboardItem) bool {
if item.Hash == v.Hash {
return true
}

return false
}) {
c.items = append(c.items, v)
}
}
}

if len(c.entries) >= c.max {
c.entries = slices.Clone(c.entries[:c.max])
c.entries = append(c.entries, toSpareEntries...)

for _, v := range toSpareEntries {
if !slices.ContainsFunc(c.entries, func(item util.Entry) bool {
if item.HashIdent == v.HashIdent {
return true
}

return false
}) {
c.entries = append(c.entries, v)
}
}
}

util.ToGob(&c.items, c.file)
Expand Down

0 comments on commit a3a4fb9

Please sign in to comment.