microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.61k stars 29.03k forks source link

Find/Replace on KDE Plasma unnecessarily overwrites clipboard when used with "clipboard selection sync" #197495

Open sporeventexplosion opened 11 months ago

sporeventexplosion commented 11 months ago

Does this issue occur when all extensions are disabled?: Yes

Version: 1.85.0-insider Commit: e55009850900a64eeb37b2228c79855ceff63914 Date: 2023-11-03T15:12:10.231Z Electron: 25.9.2 ElectronBuildId: 24603566 Chromium: 114.0.5735.289 Node.js: 18.15.0 V8: 11.4.183.29-electron.0 OS: Linux x64 6.2.0-36-generic

Steps to Reproduce:

  1. On KDE Plasma, open Klipper settings GUI and enable "Synchronize contents of the clipboard and the selection".
  2. Copy an arbitrary string to the clipboard.
  3. Open vscode with no extensions, create a new file, enter some text.
  4. Move text cursor inside one of the words, but don't select anything.
  5. Press Ctrl-F to search for the word under the current cursor. Doing this makes vscode prefill this word into the search box.
  6. Close search box and paste from clipboard.

Observed behavior

The string on the clipboard becomes the prefilled string in the search box.

Expected behavior

The original string on the clipboard is preserved.

This is the expected behavior as when focusing the address bar in Chrome and Firefox with this Klipper option enabled, the text in the address bar is auto-selected (so that it can be cleared automatically when typing a single keystroke into the address bar), but the clipboard contents are unaffected.

Also, in Firefox, one can:

Behavior identical to that described above for Firefox can be observed in LibreOffice Writer 7.3.

I think it is reasonable to expect this behavior in VS Code, as this prevents the clipboard contents from being unintentionally overwritten. It is also the behavior of multiple other major applications.

Note

I originally came across a very similar issue in FreeTubeApp/FreeTube#2019 and FreeTubeApp/FreeTube#4282, which may be relevant. I decided to test the behavior of Visual Studio Code and found this problem in this program too.

I could apparently eliminate the issue there by focusing and selecting the text in the input element asynchronously, but I don't know enough about the much more complex vscode codebase right now so I don't feel like I could open a PR just yet.

amunger commented 10 months ago

sounds like a duplicate of https://github.com/microsoft/vscode/issues/130208

sporeventexplosion commented 10 months ago

It seems in my testing that the CLIPBOARD buffer is overwritten. I did not check the contents of the PRIMARY buffer.

It's also a behavior specific to interactions with Klipper's clipboard sync functionality, so I think it's not a duplicate of #130208.

lvella commented 6 months ago

It seems to me the KDE option copies the contents of the PRIMARY buffer into the CLIPBOARD (probably vice-versa, too?) This propagates the problem of #167266 to the clipboard.