Basically, VSCode (the latest version as of 2025-04-16, but older versions are affected as well) is randomly "pasting" random text from random windows at random locations in my code. I double checked - maybe it's clipboard. But the stuff it's pasting is not even in the clipboard! It's taken from some random window I previously opened.
Imagine opening some news site, reading some news "... new tarrifs were imposed", then switching back to VSCode, trying to compile, only to see syntax errors. You check your code and see "... new tarrifs were imposed" at line 100.
I thought my keyboard/mouse were broken. I replaced them. Then I thought it was VSCode issue. Updated it. Tried it on other distros, as well as on Windows, macOS, etc, - works fine. Excepting for Ubuntu 24.04 (all latest updates applied as of 2025-04-16).
I checked other IDEs, text editors, etc, everything works fine. So it seems it's specifically related to the combination of VSCode (Electron?) + Ubuntu (Wayland?).
It's been happening for months now. How is that even possible? An OS-wide/kernel-wide memory leak? Unless the OS somehow automatically copies & pastes random things and then clears the clipboard, I can assure my clipboard is empty.
I'm starting to lose my mind, this is a programmer's nightmare fuel... Additionally, it could be a major security/privacy breach, since you'll never know when your password or other sensitive information will be "pasted" somewhere without you noticing it...
Update: that must be the middle mouse button that's driving my sanity away.
Update #2: so I can finally verify, it's not related to clipboard. I just pressed the middle mouse button, and it inserted the "Update" I texted slightly above. It seems I indeed accidentally selected that piece of text, clicked the middle mouse button, and now it's "pasting" it wherever I press it again. We have two clipboards now?.. One activated via CTRL+C/CTRL+V, another activated via the middle mouse button? Because CTRL+V does not paste what I "copied" using the middle mouse button.