nyxt icon indicating copy to clipboard operation
nyxt copied to clipboard

Remove duplicates from clipboard ring

Open aartaka opened this issue 3 years ago • 8 comments

Is your feature request related to a problem? Please describe. I like using our freshly updated clipboard ring—it expands the limits of what clipboards can do. However, I often end up with duplicate pieces of data if I do this editing sequence, for example:

  • edit text
  • copy "foo"
  • edit-text
  • copy "bar"
  • edit text
  • copy exact same "foo"

After it, clipboard ring looks like "foo", "bar", "foo". Having these duplicate entries clutters the view and makes clipboard ring much less useful.

Describe the solution you'd like Remove duplicates from the ring. My first implementation itch is to migrate to plain lists and do pushnew on them, which would be simple, fast, and dependency-free. containers:ring-buffer seems to not de-duplicate the data and is otherwise not used to its full power, so I don't see much use in it here.

Describe alternatives you've considered Obviously, my initial implementation itch may be wrong. @Ambrevar, are you maybe aware of de-duplicating data structures from e.g. containers, that we can use?

aartaka avatar Dec 27 '22 09:12 aartaka

Just a minor observation: de-duplication should be optional otherwise it can be confusing.

You expect the last thing you copied to be at the beginning of the ring, but when that thing is a duplicate then this expectation is broken.

aadcg avatar Dec 27 '22 09:12 aadcg

Yes, a good observation. Doesn't mean de-duplication should be optional, though. Emacs just shuffles the duplicate entry back at the top, and that's a pretty intuitive behavior.

aartaka avatar Dec 27 '22 09:12 aartaka

@Ambrevar, are you maybe aware of de-duplicating data structures from e.g. containers, that we can use?

Not that I know of.

Curiously I don't remember this problem. I feel like there must have been a trivial solution, but I can't remember now...

Note that if you want to switch to plain lists, it won't be equivalent to a ring, unless you constraint its length somehow.

Ambrevar avatar Jan 04 '23 09:01 Ambrevar

@Ambrevar, are you maybe aware of de-duplicating data structures from e.g. containers, that we can use?

Not that I know of.

Curiously I don't remember this problem. I feel like there must have been a trivial solution, but I can't remember now...

Yeah, feels the same to me—someone must've done this already :(

Note that if you want to switch to plain lists, it won't be equivalent to a ring, unless you constraint its length somehow.

Yes, and that feels like a benefit, because we'd no longer have suggestions deleted from the clipboard ring! More options, more suggestions, more externalized memory!

aartaka avatar Jan 09 '23 08:01 aartaka

But then you can't run the browser forever without hitting memory issues... :p

Ambrevar avatar Jan 10 '23 09:01 Ambrevar

(Generally speaking, Nyxt needs to do better with memory management!)

Ambrevar avatar Jan 10 '23 09:01 Ambrevar

But then you can't run the browser forever without hitting memory issues... :p

I second this. A ring is a more robust solution.

aadcg avatar Jan 10 '23 09:01 aadcg

Important issue.

aadcg avatar Feb 17 '25 13:02 aadcg

After reading through this thread again, I think that Andre's initial observation was correct. Doing deduplication on this data structure is confusing. There is no upside to doing deduplication. No matter what, the user will need to navigate to get to whatever entry they are interested in. Better to preserve the duplicates as is done with M-y in Emacs. It is not too arduous to just type whatever that you need.

jmercouris avatar Jun 23 '25 18:06 jmercouris