Repository: vscode
Issue: Ctrl+f overwrites X11's Primary selection buffer.
Labels: bug,linux,editor-find,editor-clipboard

- VS Code Version: 
> Version: 1.58.2
> Commit: c3f126316369cd610563c75b1b1725e0679adfb3
> Date: 2021-07-14T22:30:16.440Z
> Electron: 12.0.13
> Chrome: 89.0.4389.128
> Node.js: 14.16.0
> V8: 8.9.255.25-electron.0
> OS: Linux x64 5.4.0-80-generic snap
- OS Version: Ubuntu 20.04.2 LTS + XFce

When first exposed to X11, most people will figure out that you can paste your last selection with mouse's middle click. Many will hate the feature and disable it (so much that Ubuntu 20.04 [has disabled it by default][1]), others will learn to live with it, but a few will learn to use and depend on it. I belong in this last group, and I am used to have 2 _copy paste_ buffers: one long term (the normal ctrl+c → ctrl+v `CLIPBOARD` buffer), and one short term (the select → middle click `PRIMARY` buffer). With a few exceptions, it works transparently with most applications, but in vscode, the Find (ctrl+f) functionality disrupts the primary buffer by replacing its contents to whatever ends up being seeded in the find box.

<!-- ⚠️⚠️ 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. -->

Steps to Reproduce:

0. Make sure you have middle click paste enabled (the default in most distros I have used in the past 20 years, but I am not so sure about recent ones). [This][1] is how to do it in Ubuntu's Gnome.
1. Select any text, inside or outside vscode;
2. Middle-click several times to confirm you can paste from the `PRIMARY` buffer, inside or outside the vscode
3. Press ctrl+f in another vscode editor tab, where the cursor is over a different string (the intention is that you can middle-click and find the string you have previously selected);
4. Middle-click in the editor, to surprisingly find that the contents of your `PRIMARY` buffer has been replaced by the pre-filled contents of the Find box.

I think this is a bug because the pre-filling of the find box is certainly not intended to replace the user's copied content (and it should not).

BTW, I also think that the find box should be pre-filled with the contents of the `PRIMARY` buffer, but maybe that should be a feature request ticket.

This is somewhat related to Issue #20768.

References os this `PRIMARY` buffer thing:
- https://unix.stackexchange.com/questions/139191/whats-the-difference-between-primary-selection-and-clipboard-buffer
- https://tronche.com/gui/x/icccm/sec-2.html#s-2.6.1

[1]: https://earlruby.org/2021/01/mouse-button-copy-paste-on-ubuntu-20-04/