Repository: vscode
Issue: Find/Replace on KDE Plasma unnecessarily overwrites clipboard when used with "clipboard selection sync"
Labels: editor-find,under-discussion

<!-- ⚠️⚠️ Do Not Delete This! bug_report_template ⚠️⚠️ -->
<!-- Please read our Rules of Conduct: https://opensource.microsoft.com/codeofconduct/ -->
<!-- 🕮 Read our guide about submitting issues: https://github.com/microsoft/vscode/wiki/Submitting-Bugs-and-Suggestions -->
<!-- 🔎 Search existing issues to avoid creating duplicates. -->
<!-- 🧪 Test using the latest Insiders build to see if your issue has already been fixed: https://code.visualstudio.com/insiders/ -->
<!-- 💡 Instead of creating your report here, use 'Report Issue' from the 'Help' menu in VS Code to pre-fill useful information. -->
<!-- 🔧 Launch with `code --disable-extensions` to check. -->
Does this issue occur when all extensions are disabled?: Yes

<!-- 🪓 If you answered No above, use 'Help: Start Extension Bisect' from Command Palette to try to identify the cause. -->
<!-- 📣 Issues caused by an extension need to be reported directly to the extension publisher. The 'Help > Report Issue' dialog can assist with this. -->

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:
- select some text on a page (call this text "Text A")
- switch to another program
- copy some other text (call this text "Text B")
- switch back to the page in Firefox
- press Ctrl-F, which prefills Text A into the search box, just like VS Code (except that the text actually has to be selected, not just under the cursor)
- paste from the clipboard into the search box, or paste it somewhere else
- see that the pasted text is Text B

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.