The "reuse internal" clipboard feature cannot handle primary selections

This is a bug report.

Steps to reproduce:

  1. Run Anki-24.04.1 on X11 Linux.
  2. Copy text A from a field using Ctrl+C to put that text into the clipboard buffer.
  3. Select some other text B to put that text into the primary selection.
  4. Middle-click with the mouse to paste the primary selection.
  5. Text A from the clipboard buffer is actually pasted instead of text B from the primary selection.

Based on the code it seems like Anki tries to detect copy-and-pastes where Anki is both the source and destination of the paste. It doesn’t look like that code differentiates between a clipboard paste and primary selection paste. The code will trigger on any kind of paste and insert whatever happens to be in the clipboard buffer. This is annoying and breaks standard X11 workflows.

There is another related problem in how Anki handles formatting. If I copy text internally using the primary selection, any formatting is stripped, but if I do the same copy using the clipboard buffer the formatting is retained. This is true even when “Paste without shift key strips formatting” is enabled. I would expect both types of paste to work consistently and I would prefer if all formatting were stripped in all cases. Just because I want to copy a word from one field to another doesn’t mean I want to also copy whatever formatting that word has. I cannot think of any situation where I would like to keep formatting. Instead I would like the “Paste without shift key strips formatting” option to be honored in all cases.

1 Like

I’ve logged this on The “reuse internal” clipboard feature cannot handle primary selections · Issue #3249 · ankitects/anki · GitHub

2 Likes

Before I was able to use the middle click paste. So to me it seems this regression got introduced quite recently. Maybe it’s possible to bisect to find out what happened.